Permalink
Browse files

Merge pull request #457 from rdavaillaud/fix-311-table_declared_twice

Fix the 'Table "t1" declared twice' when same table name are declared on...
  • Loading branch information...
2 parents 19dc671 + b692286 commit 6234fec72db2ad8fc0fe6e1ea6c1cd76abeeef5a @willdurand willdurand committed Aug 28, 2012
Showing with 16 additions and 1 deletion.
  1. +1 −1 generator/lib/model/Database.php
  2. +15 −0 test/testsuite/generator/model/DatabaseTest.php
@@ -379,10 +379,10 @@ public function addTable($data)
{
if ($data instanceof Table) {
$tbl = $data; // alias
+ $tbl->setDatabase($this);
if (isset($this->tablesByName[$tbl->getName()])) {
throw new EngineException(sprintf('Table "%s" declared twice', $tbl->getName()));
}
- $tbl->setDatabase($this);
if ($tbl->getSchema() === null) {
$tbl->setSchema($this->getSchema());
}
@@ -128,4 +128,19 @@ public function testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute()
$this->assertEquals('Bar', $t1->getNamespace());
}
+ public function testAddTableWithSameNameOnDifferentSchema()
+ {
+ $db = new Database();
+ $db->setPlatform(new SchemaPlatform());
+
+ $t1 = new Table('t1');
+ $db->addTable($t1);
+ $this->assertEquals('t1', $t1->getName());
+
+ $t1b = new Table('t1');
+ $t1b->setSchema('bis');
+ $db->addTable($t1b);
+ $this->assertEquals('bis.t1', $t1b->getName());
+ }
+
}

0 comments on commit 6234fec

Please sign in to comment.