Skip to content

Commit

Permalink
Remove 'self' key from getConstraint() calculations because it is not…
Browse files Browse the repository at this point in the history
… necessary anymore.
  • Loading branch information
bar committed Nov 12, 2013
1 parent e658e07 commit 014d2dd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -1320,7 +1320,7 @@ public function queryAssociation(Model $Model, &$LinkModel, $type, $association,
}
}

$selfJoin = ($LinkModel->name === $Model->name);
$selfJoin = ($Model->name === $LinkModel->name);

if (!empty($fetch) && is_array($fetch)) {
if ($recursive > 0) {
Expand Down Expand Up @@ -1605,14 +1605,14 @@ public function generateAssociationQuery(Model $Model, $linkModel, $type, $assoc
switch ($type) {
case 'hasOne':
case 'belongsTo':
$self = ($Model->name === $linkModel->name);

$conditions = $this->_mergeConditions(
$assocData['conditions'],
$this->getConstraint($type, $Model, $linkModel, $association, array_merge($assocData, compact('external', 'self')))
$this->getConstraint($type, $Model, $linkModel, $association, array_merge($assocData, compact('external')))
);

if (!$self && $external) {
$selfJoin = ($Model->name === $linkModel->name);

if ($external && !$selfJoin) {
$modelAlias = $Model->alias;
foreach ($conditions as $key => $condition) {
if (is_numeric($key) && strpos($condition, $modelAlias . '.') !== false) {
Expand Down Expand Up @@ -1733,7 +1733,7 @@ public function generateAssociationQuery(Model $Model, $linkModel, $type, $assoc
* @return array Conditions array defining the constraint between $model and $association
*/
public function getConstraint($type, $model, $linkModel, $alias, $assoc, $alias2 = null) {
$assoc += array('external' => false, 'self' => false);
$assoc += array('external' => false);

if (empty($assoc['foreignKey'])) {
return array();
Expand Down

0 comments on commit 014d2dd

Please sign in to comment.