Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from Mixotv/master

Use the parent PK type in the jointure table PK.
  • Loading branch information...
commit 85b91f2a9ebb4bb89464292585de6d5d2def4e99 2 parents ed33134 + 5f2b77c
@willdurand willdurand authored
Showing with 28 additions and 2 deletions.
  1. +2 −2 src/EqualNestBehavior.php
  2. +26 −0 tests/EqualNestBehaviorTest.php
View
4 src/EqualNestBehavior.php
@@ -42,7 +42,7 @@ public function modifyTable()
$this->getTable()->addColumn(array(
'name' => $this->getReferenceColumn1Name(),
'primaryKey' => 'true',
- 'type' => 'INTEGER'
+ 'type' => $parentTablePrimaryKey[0]->getType(),
));
$fk = new ForeignKey();
@@ -58,7 +58,7 @@ public function modifyTable()
$this->getTable()->addColumn(array(
'name' => $this->getReferenceColumn2Name(),
'primaryKey' => 'true',
- 'type' => 'INTEGER',
+ 'type' => $parentTablePrimaryKey[0]->getType(),
));
$fk = new ForeignKey();
View
26 tests/EqualNestBehaviorTest.php
@@ -466,4 +466,30 @@ public function testMultiplePksInParentTableThrowsException()
XML;
$this->getBuilder($schema)->build();
}
+
+ public function testPkMatchParentPkType(){
+ $schema = <<<XML
+<database name="equal_nest_behavior_4">
+ <table name="person_4">
+ <column name="id" required="true" primaryKey="true" autoIncrement="true" type="BIGINT" />
+ <column name="name" type="VARCHAR" required="true" />
+ </table>
+
+ <table name="friend_4">
+ <behavior name="equal_nest">
+ <parameter name="parent_table" value="person_4" />
+ </behavior>
+ </table>
+</database>
+XML;
+ $build = $this->getBuilder($schema)->build();
+ $parentTable = new Person4TableMap();
+ $table = new Friend4TableMap();
+
+ list($parentKey) = $parentTable->getPrimaryKeyColumns();
+ $pks = $table->getPrimaryKeyColumns();
+ foreach($pks as $pk) {
+ $this->assertTrue($pk->getType() === $parentKey->getType());
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.