Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix: issue #301

  • Loading branch information...
commit 8b84a20e7e4c03c4d206ce6bbd7d10eb791e638c 1 parent c8dcbc9
Kévin Gomez authored August 29, 2012
3  src/Propel/Generator/Model/Database.php
@@ -416,11 +416,12 @@ public function addTable($table)
416 416
             return $this->addTable($tbl);
417 417
         }
418 418
 
  419
+        $table->setDatabase($this);
  420
+
419 421
         if (isset($this->tablesByName[$table->getName()])) {
420 422
             throw new EngineException(sprintf('Table "%s" declared twice', $table->getName()));
421 423
         }
422 424
 
423  
-        $table->setDatabase($this);
424 425
         if (null === $table->getSchema()) {
425 426
             $table->setSchema($this->getSchema());
426 427
         }
17  tests/Propel/Tests/Generator/Model/DatabaseTest.php
@@ -11,6 +11,8 @@
11 11
 namespace Propel\Tests\Generator\Model;
12 12
 
13 13
 use Propel\Generator\Model\Database;
  14
+use Propel\Generator\Model\Table;
  15
+use Propel\Generator\Platform\PgsqlPlatform;
14 16
 
15 17
 /**
16 18
  * Unit test suite for Database model class.
@@ -418,4 +420,19 @@ public function testSetDefaultPhpNamingMethodStrategy()
418 420
 
419 421
         $this->assertSame('foo', $database->getDefaultPhpNamingMethod());
420 422
     }
  423
+
  424
+    public function testAddTableWithSameNameOnDifferentSchema()
  425
+    {
  426
+        $db = new Database();
  427
+        $db->setPlatform(new PgsqlPlatform());
  428
+
  429
+        $t1 = new Table('t1');
  430
+        $db->addTable($t1);
  431
+        $this->assertEquals('t1', $t1->getName());
  432
+
  433
+        $t1b = new Table('t1');
  434
+        $t1b->setSchema('bis');
  435
+        $db->addTable($t1b);
  436
+        $this->assertEquals('bis.t1', $t1b->getName());
  437
+    }
421 438
 }

0 notes on commit 8b84a20

Please sign in to comment.
Something went wrong with that request. Please try again.