Browse Source

Merge pull request #8521 from cakephp/issue-8510

Alias conditions in BelongsToMany.
José Lorenzo Rodríguez 10 years ago
parent
commit
47bb74fe86
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/ORM/Association/BelongsToMany.php

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

@@ -988,7 +988,7 @@ class BelongsToMany extends Association
 
         return $this->junction()->connection()->transactional(
             function () use ($sourceEntity, $targetEntities, $primaryValue, $options) {
-                $foreignKey = (array)$this->foreignKey();
+                $foreignKey = array_map([$this->_junctionTable, 'aliasField'], (array)$this->foreignKey());
                 $hasMany = $this->source()->association($this->_junctionTable->alias());
                 $existing = $hasMany->find('all')
                     ->where(array_combine($foreignKey, $primaryValue));