Permalink
Browse files

Merge pull request #762 from javer/patch-diff-skipsql

Fixed diff task combined with skipSql
  • Loading branch information...
2 parents 50c2274 + 041af74 commit 7a708f7caaf01227e238467c87d62fedbe818853 @willdurand willdurand committed Oct 10, 2013
@@ -130,7 +130,7 @@ public function compareTables($caseInsensitive = false)
// check for table differences
foreach ($fromDatabaseTables as $fromTable) {
- if ($this->toDatabase->hasTable($fromTable->getName(), $caseInsensitive)) {
+ if ($this->toDatabase->hasTable($fromTable->getName(), $caseInsensitive) && !$fromTable->isSkipSql()) {
$toTable = $this->toDatabase->getTable($fromTable->getName(), $caseInsensitive);
$databaseDiff = PropelTableComparator::computeDiff($fromTable, $toTable, $caseInsensitive);
if ($databaseDiff) {
@@ -265,6 +265,45 @@ public function testCompareModifiedTable()
$this->assertEquals(array('Foo_Table' => $tableDiff), $databaseDiff->getModifiedTables());
}
+ public function testCompareModifiedTableSkipSql()
+ {
+ $d1 = new Database();
+ $t1 = new Table('Foo_Table');
+ $c1 = new Column('Foo');
+ $c1->getDomain()->copy($this->platform->getDomainForType('DOUBLE'));
+ $c1->getDomain()->replaceScale(2);
+ $c1->getDomain()->replaceSize(3);
+ $c1->setNotNull(true);
+ $c1->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
+ $t1->addColumn($c1);
+ $c2 = new Column('Foo2');
+ $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
+ $t1->addColumn($c2);
+ $t1->setSkipSql(true);
+ $d1->addTable($t1);
+ $t2 = new Table('Bar');
+ $d1->addTable($t2);
+
+ $d2 = new Database();
+ $t3 = new Table('Foo_Table');
+ $c3 = new Column('Foo');
+ $c3->getDomain()->copy($this->platform->getDomainForType('DOUBLE'));
+ $c3->getDomain()->replaceScale(2);
+ $c3->getDomain()->replaceSize(3);
+ $c3->setNotNull(true);
+ $c3->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
+ $t3->addColumn($c3);
+ $d2->addTable($t3);
+ $t4 = new Table('Bar');
+ $d2->addTable($t4);
+
+ $dc = new PropelDatabaseComparator();
+ $dc->setFromDatabase($d1);
+ $dc->setToDatabase($d2);
+ $nbDiffs = $dc->compareTables();
+ $this->assertEquals(0, $nbDiffs);
+ }
+
public function testCompareRenamedTable()
{
$d1 = new Database();

0 comments on commit 7a708f7

Please sign in to comment.