Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into sortable_scope
Browse files Browse the repository at this point in the history
  • Loading branch information
rozwell committed Sep 5, 2012
2 parents ed54050 + 6234fec commit 811d0f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generator/lib/model/Database.php
Expand Up @@ -379,10 +379,10 @@ public function addTable($data)
{ {
if ($data instanceof Table) { if ($data instanceof Table) {
$tbl = $data; // alias $tbl = $data; // alias
$tbl->setDatabase($this);
if (isset($this->tablesByName[$tbl->getName()])) { if (isset($this->tablesByName[$tbl->getName()])) {
throw new EngineException(sprintf('Table "%s" declared twice', $tbl->getName())); throw new EngineException(sprintf('Table "%s" declared twice', $tbl->getName()));
} }
$tbl->setDatabase($this);
if ($tbl->getSchema() === null) { if ($tbl->getSchema() === null) {
$tbl->setSchema($this->getSchema()); $tbl->setSchema($this->getSchema());
} }
Expand Down
15 changes: 15 additions & 0 deletions test/testsuite/generator/model/DatabaseTest.php
Expand Up @@ -128,4 +128,19 @@ public function testAddTableSkipsDatabaseNamespaceWhenTableNamespaceIsAbsolute()
$this->assertEquals('Bar', $t1->getNamespace()); $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 811d0f0

Please sign in to comment.