Commit d6ee8aa7 authored by Steve Müller's avatar Steve Müller

fix GUID type comparator issues

parent 0b609e49
......@@ -399,7 +399,9 @@ class Comparator
$changedProperties[] = 'default';
}
if ($properties1['type'] instanceof Types\StringType || $properties1['type'] instanceof Types\BinaryType) {
if (($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) ||
$properties1['type'] instanceof Types\BinaryType
) {
// check if value of length is set at all, default value assumed otherwise.
$length1 = $properties1['length'] ?: 255;
$length2 = $properties2['length'] ?: 255;
......
......@@ -259,4 +259,24 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$platform->getBlobTypeDeclarationSQL($onlineColumns['col_longblob']->toArray())
);
}
/**
* @group DBAL-423
*/
public function testDiffListGuidTableColumn()
{
$offlineTable = new Table('list_guid_table_column');
$offlineTable->addColumn('col_guid', 'guid');
$this->_sm->dropAndCreateTable($offlineTable);
$onlineTable = $this->_sm->listTableDetails('list_guid_table_column');
$comparator = new Comparator();
$this->assertFalse(
$comparator->diffTable($offlineTable, $onlineTable),
"No differences should be detected with the offline vs online schema."
);
}
}
......@@ -1107,4 +1107,19 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $comparator->compare($fromSchema, $toSchema));
}
public function testCompareGuidColumns()
{
$comparator = new Comparator();
$column1 = new Column('foo', Type::getType('guid'), array('comment' => 'GUID 1'));
$column2 = new Column(
'foo',
Type::getType('guid'),
array('notnull' => false, 'length' => '36', 'fixed' => true, 'default' => 'NEWID()', 'comment' => 'GUID 2.')
);
$this->assertEquals(array('notnull', 'default', 'comment'), $comparator->diffColumn($column1, $column2));
$this->assertEquals(array('notnull', 'default', 'comment'), $comparator->diffColumn($column2, $column1));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment