Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 6234fec72db2ad8fc0fe6e1ea6c1cd76abeeef5a 2 parents 19dc671 + b692286
William Durand willdurand authored
2  generator/lib/model/Database.php
View
@@ -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());
}
15 test/testsuite/generator/model/DatabaseTest.php
View
@@ -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());
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.