Skip to content

Commit 5c9bef5

Browse files
committed
allow to use non-primary columns in crossref tables
1 parent 897c198 commit 5c9bef5

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Propel/Generator/Model/CrossForeignKeys.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ public function getIncomingForeignKey()
130130
* @param ForeignKey $fk
131131
* @return bool
132132
*/
133-
public function isAtLeastOneLocalPrimaryKeyNotCovered(ForeignKey $fk)
133+
public function isAtLeastOneLocalColumnNotCovered(ForeignKey $fk)
134134
{
135-
$primaryKeys = $fk->getLocalPrimaryKeys();
135+
$primaryKeys = $fk->getLocalColumnObjects();
136136
foreach ($primaryKeys as $primaryKey) {
137137
$covered = false;
138138
foreach ($this->getCrossForeignKeys() as $crossFK) {

src/Propel/Generator/Model/ForeignKey.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,9 @@ public function isAtLeastOneLocalColumnRequired()
765765
*
766766
* @return boolean
767767
*/
768-
public function isAtLeastOneLocalPrimaryKeyIsRequired()
768+
public function isAtLeastOneLocalColumnIsRequired()
769769
{
770-
foreach ($this->getLocalPrimaryKeys() as $pk) {
770+
foreach ($this->getLocalColumnObjects() as $pk) {
771771
if ($pk->isNotNull() && !$pk->hasDefaultValue()) {
772772
return true;
773773
}

src/Propel/Generator/Model/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ public function getCrossFks()
821821
if ($refFK->getTable()->isCrossRef()) {
822822
$crossFK = new CrossForeignKeys($refFK, $this);
823823
foreach ($refFK->getOtherFks() as $fk) {
824-
if ($fk->isAtLeastOneLocalPrimaryKeyIsRequired() &&
825-
$crossFK->isAtLeastOneLocalPrimaryKeyNotCovered($fk)) {
824+
if ($fk->isAtLeastOneLocalColumnIsRequired() &&
825+
$crossFK->isAtLeastOneLocalColumnNotCovered($fk)) {
826826
$crossFK->addCrossForeignKey($fk);
827827
}
828828
}

0 commit comments

Comments
 (0)