Skip to content

Commit 9ca8488

Browse files
committed
Reverting some changes done in previous commit, they were not actually
needed
1 parent e4fbba3 commit 9ca8488

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/Cake/ORM/Association.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public function attachTo(Query $query, array $options = []) {
369369
}
370370

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

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

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

@@ -392,7 +392,8 @@ public function attachTo(Query $query, array $options = []) {
392392
*/
393393
public function transformRow($row) {
394394
$sourceAlias = $this->source()->alias();
395-
$row[$sourceAlias][$this->property()] = $row[$this->_name];
395+
$targetAlias = $this->target()->alias();
396+
$row[$sourceAlias][$this->property()] = $row[$targetAlias];
396397
return $row;
397398
}
398399

lib/Cake/ORM/Association/BelongsTo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function foreignKey($key = null) {
6161
*/
6262
protected function _joinCondition(array $options) {
6363
return sprintf('%s.%s = %s.%s',
64-
$this->_name,
64+
$this->target()->alias(),
6565
$this->_targetTable->primaryKey(),
6666
$this->_sourceTable->alias(),
6767
$options['foreignKey']

lib/Cake/ORM/Association/ExternalAssociationTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ protected function _buildSubquery($query, $foreignKey) {
238238
unset($joins[$i]);
239239
}
240240
}
241-
242241
$filterQuery->join($joins, [], true);
243242
return $filterQuery->select($foreignKey, true);
244243
}

0 commit comments

Comments
 (0)