Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix: issue #301 #302

Merged
merged 1 commit into from Aug 31, 2012
Jump to file or symbol
Failed to load files and symbols.
+19 −1
Split
@@ -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());
}
@@ -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());
+ }
}