Permalink
Browse files

Fix: issue #301

  • Loading branch information...
1 parent c8dcbc9 commit 8b84a20e7e4c03c4d206ce6bbd7d10eb791e638c @K-Phoen K-Phoen committed Aug 29, 2012
Showing with 19 additions and 1 deletion.
  1. +2 −1 src/Propel/Generator/Model/Database.php
  2. +17 −0 tests/Propel/Tests/Generator/Model/DatabaseTest.php
View
3 src/Propel/Generator/Model/Database.php
@@ -416,11 +416,12 @@ public function addTable($table)
return $this->addTable($tbl);
}
+ $table->setDatabase($this);
+
if (isset($this->tablesByName[$table->getName()])) {
throw new EngineException(sprintf('Table "%s" declared twice', $table->getName()));
}
- $table->setDatabase($this);
if (null === $table->getSchema()) {
$table->setSchema($this->getSchema());
}
View
17 tests/Propel/Tests/Generator/Model/DatabaseTest.php
@@ -11,6 +11,8 @@
namespace Propel\Tests\Generator\Model;
use Propel\Generator\Model\Database;
+use Propel\Generator\Model\Table;
+use Propel\Generator\Platform\PgsqlPlatform;
/**
* Unit test suite for Database model class.
@@ -418,4 +420,19 @@ public function testSetDefaultPhpNamingMethodStrategy()
$this->assertSame('foo', $database->getDefaultPhpNamingMethod());
}
+
+ public function testAddTableWithSameNameOnDifferentSchema()
+ {
+ $db = new Database();
+ $db->setPlatform(new PgsqlPlatform());
+
+ $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 8b84a20

Please sign in to comment.