Fixed calculation of differences of columns #320

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@hason
Contributor
hason commented May 17, 2013

No description provided.

@Ocramius Ocramius commented on an outdated diff May 17, 2013
lib/Doctrine/DBAL/Schema/Comparator.php
- if ($column1->getNotnull() != $column2->getNotnull()) {
- $changedProperties[] = 'notnull';
- }
-
- if ($column1->getDefault() != $column2->getDefault()) {
- $changedProperties[] = 'default';
- }
-
- if ($column1->getUnsigned() != $column2->getUnsigned()) {
- $changedProperties[] = 'unsigned';
+ $changedProperties = array();
+ foreach (array('type', 'notnull', 'default', 'unsigned', 'autoincrement') as $property) {
+ if ($properties1[$property] != $properties2[$property]) {
@Ocramius
Ocramius May 17, 2013 Member

Should this use strict comparison?

@Ocramius Ocramius commented on an outdated diff May 17, 2013
lib/Doctrine/DBAL/Schema/Comparator.php
}
- if ($column1->getType() instanceof \Doctrine\DBAL\Types\StringType) {
+ if ($properties1['type'] instanceof \Doctrine\DBAL\Types\StringType) {
@Ocramius
Ocramius May 17, 2013 Member

Import StringType

@Ocramius Ocramius commented on an outdated diff May 17, 2013
lib/Doctrine/DBAL/Schema/Comparator.php
$changedProperties[] = 'fixed';
}
- }
-
- if ($column1->getType() instanceof \Doctrine\DBAL\Types\DecimalType) {
- if (($column1->getPrecision()?:10) != ($column2->getPrecision()?:10)) {
+ } elseif ($properties1['type'] instanceof \Doctrine\DBAL\Types\DecimalType) {
@Ocramius
Ocramius May 17, 2013 Member

Import DecimalType

@Ocramius
Member

Not sure about the comparisons: what kind of objects are being compared here?

@beberlei
Member

Please explain the commit in more detail

@hason
Contributor
hason commented Oct 23, 2013

Same functionality in #245

@hason hason closed this Oct 23, 2013
@hason hason deleted the hason:comparator branch Feb 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment