Skip to content

Commit

Permalink
Fix: issue #301
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Aug 29, 2012
1 parent c8dcbc9 commit 8b84a20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Propel/Generator/Model/Database.php
Expand Up @@ -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());
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Propel/Tests/Generator/Model/DatabaseTest.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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.