Permalink
Browse files

Fixed diff generator when several identical tables were renamed

Fixed diff generator when databases have several tables with identical
DDL and several of them were renamed.
  • Loading branch information...
1 parent f62d334 commit b313c3d0249a12bb7e42fcf5092ce3e9ed0315dd @javer javer committed Mar 5, 2014
@@ -149,6 +149,8 @@ public function compareTables($caseInsensitive = false)
$this->databaseDiff->removeAddedTable($addedTableName);
$this->databaseDiff->removeRemovedTable($removedTableName);
$databaseDifferences--;
+ // skip to the next added table
+ break;
}
}
}
@@ -154,7 +154,7 @@ public function compareColumns($caseInsensitive = false)
$this->tableDiff->removeRemovedColumn($removedColumnName);
$columnDifferences--;
// skip to the next added column
- continue 2;
+ break;
}
}
}
@@ -204,7 +204,7 @@ public function comparePrimaryKeys($caseInsensitive = false)
$this->tableDiff->removeRemovedPkColumn($removedColumnName);
$pkDifferences--;
// skip to the next added column
- continue 2;
+ break;
}
}
}
@@ -399,4 +399,52 @@ public function testCompareSeveralTableDifferences()
$this->assertEquals(array('Foo_Table' => $tableDiff), $databaseDiff->getModifiedTables());
}
+ public function testCompareSeveralRenamedSameTables()
+ {
+ $d1 = new Database();
+ $t1 = new Table('table1');
+ $c1 = new Column('col1');
+ $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t1->addColumn($c1);
+ $d1->addTable($t1);
+ $t2 = new Table('table2');
+ $c2 = new Column('col1');
+ $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t2->addColumn($c2);
+ $d1->addTable($t2);
+ $t3 = new Table('table3');
+ $c3 = new Column('col1');
+ $c3->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t3->addColumn($c3);
+ $d1->addTable($t3);
+
+ $d2 = new Database();
+ $t4 = new Table('table4');
+ $c4 = new Column('col1');
+ $c4->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t4->addColumn($c4);
+ $d2->addTable($t4);
+ $t5 = new Table('table5');
+ $c5 = new Column('col1');
+ $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t5->addColumn($c5);
+ $d2->addTable($t5);
+ $t6 = new Table('table3');
+ $c6 = new Column('col1');
+ $c6->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t6->addColumn($c6);
+ $d2->addTable($t6);
+
+ $dc = new PropelDatabaseComparator();
+ $dc->setFromDatabase($d1);
+ $dc->setToDatabase($d2);
+ $nbDiffs = $dc->compareTables();
+ $databaseDiff = $dc->getDatabaseDiff();
+ $this->assertEquals(2, $nbDiffs);
+ $this->assertEquals(2, count($databaseDiff->getRenamedTables()));
+ $this->assertEquals(array('table1' => 'table4', 'table2' => 'table5'), $databaseDiff->getRenamedTables());
+ $this->assertEquals(array(), $databaseDiff->getAddedTables());
+ $this->assertEquals(array(), $databaseDiff->getRemovedTables());
+ }
+
}

0 comments on commit b313c3d

Please sign in to comment.