Browse Source

fixes wrong foreignKey to find the association

was using the foreignKey for the source table ("foreignKey") and not the foreignKey for the target table ("targetForeignKey")
Frederik Bauer 10 years ago
parent
commit
c8b600015c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/ORM/Association/BelongsToMany.php

+ 1 - 1
src/ORM/Association/BelongsToMany.php

@@ -894,7 +894,7 @@ class BelongsToMany extends Association
 
 
         $belongsTo = $this->junction()->association($this->target()->alias());
         $belongsTo = $this->junction()->association($this->target()->alias());
         $conditions = $belongsTo->_joinCondition([
         $conditions = $belongsTo->_joinCondition([
-            'foreignKey' => $this->foreignKey()
+            'foreignKey' => $this->targetForeignKey()
         ]);
         ]);
         $conditions += $this->junctionConditions();
         $conditions += $this->junctionConditions();
         return $this->_appendJunctionJoin($query, $conditions);
         return $this->_appendJunctionJoin($query, $conditions);