Commit 4e024dcb authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge branch 'DBAL-617' into 2.4

parents 121332f1 03827efe
......@@ -322,11 +322,11 @@ class Comparator
*/
public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint $key2)
{
if (array_map('strtolower', $key1->getLocalColumns()) != array_map('strtolower', $key2->getLocalColumns())) {
if (array_map('strtolower', $key1->getUnquotedLocalColumns()) != array_map('strtolower', $key2->getUnquotedLocalColumns())) {
return true;
}
if (array_map('strtolower', $key1->getForeignColumns()) != array_map('strtolower', $key2->getForeignColumns())) {
if (array_map('strtolower', $key1->getUnquotedForeignColumns()) != array_map('strtolower', $key2->getUnquotedForeignColumns())) {
return true;
}
......
......@@ -163,6 +163,26 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
return $columns;
}
/**
* Returns unquoted representation of local table column names for comparison with other FK
*
* @return array
*/
public function getUnquotedLocalColumns()
{
return array_map(array($this, 'trimQuotes'), $this->getLocalColumns());
}
/**
* Returns unquoted representation of foreign table column names for comparison with other FK
*
* @return array
*/
public function getUnquotedForeignColumns()
{
return array_map(array($this, 'trimQuotes'), $this->getForeignColumns());
}
/**
* {@inheritdoc}
*
......
......@@ -913,6 +913,20 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
}
/**
* @group DBAL-617
*/
public function testCompareQuotedAndUnquotedForeignKeyColumns()
{
$fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION'));
$fk2 = new ForeignKeyConstraint(array("`foo`"), "bar", array("`baz`"), "fk1", array('onDelete' => 'NO ACTION'));
$comparator = new Comparator();
$diff = $comparator->diffForeignKey($fk1, $fk2);
$this->assertFalse($diff);
}
/**
* @param SchemaDiff $diff
* @param int $newTableCount
......
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