Skip to content

Commit

Permalink
Stop calling limit() twice on the same data.
Browse files Browse the repository at this point in the history
DboSource::limit() now follows its documented input types, passing an
already formatted LIMIT string will result in LIMIT 0. Remove useless
array merging as well.
  • Loading branch information
markstory committed May 3, 2013
1 parent 2096d3f commit 7b0af65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -1529,7 +1529,6 @@ public function generateAssociationQuery(Model $model, $linkModel, $type, $assoc
if (empty($assocData['offset']) && !empty($assocData['page'])) {
$assocData['offset'] = ($assocData['page'] - 1) * $assocData['limit'];
}
$assocData['limit'] = $this->limit($assocData['limit'], $assocData['offset']);

switch ($type) {
case 'hasOne':
Expand All @@ -1555,7 +1554,6 @@ public function generateAssociationQuery(Model $model, $linkModel, $type, $assoc
'alias' => $association,
'group' => null
));
$query += array('order' => $assocData['order'], 'limit' => $assocData['limit']);
} else {
$join = array(
'table' => $linkModel,
Expand Down Expand Up @@ -1586,6 +1584,7 @@ public function generateAssociationQuery(Model $model, $linkModel, $type, $assoc
'alias' => $association,
'order' => $assocData['order'],
'limit' => $assocData['limit'],
'offset' => $assocData['offset'],
'group' => null
);
break;
Expand Down Expand Up @@ -1613,6 +1612,7 @@ public function generateAssociationQuery(Model $model, $linkModel, $type, $assoc
$query = array(
'conditions' => $assocData['conditions'],
'limit' => $assocData['limit'],
'offset' => $assocData['offset'],
'table' => $this->fullTableName($linkModel),
'alias' => $association,
'fields' => array_merge($this->fields($linkModel, $association, $assocData['fields']), $joinFields),
Expand Down

0 comments on commit 7b0af65

Please sign in to comment.