Skip to content
Permalink
Browse files

Only array-wrap 'order' if it's not already an array.

  • Loading branch information...
dereuromark committed Sep 22, 2015
1 parent 851ff44 commit 81cbb52f74e9380f3b666c9bf609686b7ab23988
Showing with 3 additions and 3 deletions.
  1. +1 −1 lib/Cake/Model/Model.php
  2. +2 −2 lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
@@ -3071,7 +3071,7 @@ public function buildQuery($type = 'first', $query = array()) {
$query['order'] = $this->order;
}
$query['order'] = array($query['order']);
$query['order'] = (array)$query['order'];
if ($query['callbacks'] === true || $query['callbacks'] === 'before') {
$event = new CakeEvent('Model.beforeFind', $this, array($query));
@@ -361,13 +361,13 @@ public function testPaginate() {
$Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc', 'limit' => 2);
$Controller->Paginator->paginate('PaginatorControllerPost');
$this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']);
$this->assertEquals(array(), $Controller->PaginatorControllerPost->lastQueries[1]['order'][0], 'no order should be set.');
$this->assertEquals(array(), $Controller->PaginatorControllerPost->lastQueries[1]['order'], 'no order should be set.');
$Controller->request->params['named'] = array(
'sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase'
);
$results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id');
$this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[0]['order'][0]);
$this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[0]['order']);
$this->assertEquals(array(1, 3, 2), $results);
$Controller->request->params['named'] = array();

0 comments on commit 81cbb52

Please sign in to comment.
You can’t perform that action at this time.