Skip to content

Commit

Permalink
Reverting some changes done in previous commit, they were not actually
Browse files Browse the repository at this point in the history
needed
  • Loading branch information
lorenzo committed Jun 11, 2013
1 parent e4fbba3 commit 9ca8488
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/Cake/ORM/Association.php
Expand Up @@ -369,7 +369,7 @@ public function attachTo(Query $query, array $options = []) {
}

$joinOptions = ['table' => 1, 'conditions' => 1, 'type' => 1];
$query->join([$this->_name => array_intersect_key($options, $joinOptions)]);
$query->join([$target->alias() => array_intersect_key($options, $joinOptions)]);

if (empty($options['fields'])) {
$f = isset($options['fields']) ? $options['fields'] : null;
Expand All @@ -379,7 +379,7 @@ public function attachTo(Query $query, array $options = []) {
}

if (!empty($options['fields'])) {
$query->select($query->aliasFields($options['fields'], $this->_name));
$query->select($query->aliasFields($options['fields'], $target->alias()));
}
}

Expand All @@ -392,7 +392,8 @@ public function attachTo(Query $query, array $options = []) {
*/
public function transformRow($row) {
$sourceAlias = $this->source()->alias();
$row[$sourceAlias][$this->property()] = $row[$this->_name];
$targetAlias = $this->target()->alias();
$row[$sourceAlias][$this->property()] = $row[$targetAlias];
return $row;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/ORM/Association/BelongsTo.php
Expand Up @@ -61,7 +61,7 @@ public function foreignKey($key = null) {
*/
protected function _joinCondition(array $options) {
return sprintf('%s.%s = %s.%s',
$this->_name,
$this->target()->alias(),
$this->_targetTable->primaryKey(),
$this->_sourceTable->alias(),
$options['foreignKey']
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/ORM/Association/ExternalAssociationTrait.php
Expand Up @@ -238,7 +238,6 @@ protected function _buildSubquery($query, $foreignKey) {
unset($joins[$i]);
}
}

$filterQuery->join($joins, [], true);
return $filterQuery->select($foreignKey, true);
}
Expand Down

0 comments on commit 9ca8488

Please sign in to comment.