Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix the 'Table "t1" declared twice' when same table name are declared on... #457

Merged
merged 2 commits into from

4 participants

@rdavaillaud

... different schema fix #311

test/testsuite/generator/model/DatabaseTest.php
@@ -1,4 +1,4 @@
-<?php
+ <?php
@rozwell
rozwell added a note

I guess you want to remove this space :)

damn! you're right ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@travisbot

This pull request passes (merged 725518f into 19dc671).

@travisbot

This pull request passes (merged b692286 into 19dc671).

@willdurand
Owner

Great! That's a wonderful fix, thanks!

@willdurand willdurand merged commit 6234fec into propelorm:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  generator/lib/model/Database.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());
}
View
15 test/testsuite/generator/model/DatabaseTest.php
@@ -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());
+ }
+
}
Something went wrong with that request. Please try again.