diff --git a/src/Propel/Generator/Model/CrossForeignKeys.php b/src/Propel/Generator/Model/CrossForeignKeys.php index c9bd647b6..61a09ff3a 100644 --- a/src/Propel/Generator/Model/CrossForeignKeys.php +++ b/src/Propel/Generator/Model/CrossForeignKeys.php @@ -132,7 +132,7 @@ public function getIncomingForeignKey(): ?ForeignKey */ public function isAtLeastOneLocalPrimaryKeyNotCovered(ForeignKey $fk): bool { - $primaryKeys = $fk->getLocalPrimaryKeys(); + $primaryKeys = $fk->getLocalColumnObjects(); foreach ($primaryKeys as $primaryKey) { $covered = false; foreach ($this->getCrossForeignKeys() as $crossFK) { diff --git a/src/Propel/Generator/Model/ForeignKey.php b/src/Propel/Generator/Model/ForeignKey.php index ac7c5c25c..b8da10a94 100644 --- a/src/Propel/Generator/Model/ForeignKey.php +++ b/src/Propel/Generator/Model/ForeignKey.php @@ -874,7 +874,7 @@ public function isAtLeastOneLocalColumnRequired(): bool */ public function isAtLeastOneLocalPrimaryKeyIsRequired(): bool { - foreach ($this->getLocalPrimaryKeys() as $pk) { + foreach ($this->getLocalColumnObjects() as $pk) { if ($pk->isNotNull() && !$pk->hasDefaultValue()) { return true; } diff --git a/tests/Propel/Tests/Issues/IssueIsCrossRefTest.php b/tests/Propel/Tests/Issues/IssueIsCrossRefTest.php new file mode 100644 index 000000000..5e810d36e --- /dev/null +++ b/tests/Propel/Tests/Issues/IssueIsCrossRefTest.php @@ -0,0 +1,98 @@ + + + +
+ + +
+ + +
+ + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ +EOF; + QuickBuilder::buildSchema($schema); + } + } + + /** + * @return void + */ + public function testGenerateIsCrossRefCode() + { + $testGroupObject = new TestGroupObject(); + $testUserObject = new TestUserObject(); + $testGroupNegative = new TestGroupObjectNegative(); + $testUserNegative = new TestUserObjectNegative(); + + $this->assertTrue( + method_exists($testGroupObject, 'createTestUserObjectsQuery'), + 'Class does not have method createTestUserObjectsQuery' + ); + $this->assertTrue( + method_exists($testUserObject, 'createTestGroupObjectsQuery'), + 'Class does not have method createTestUserObjectsQuery' + ); + $this->assertFalse( + method_exists($testGroupNegative, 'createTestUserObjectNegativesQuery'), + 'Class does not have method createTestUserObjectsQuery' + ); + $this->assertFalse( + method_exists($testUserNegative, 'createTestGroupObjectNegativesQuery'), + 'Class does not have method createTestUserObjectsQuery' + ); + } +}