Skip to content

Commit

Permalink
Working on virtual fields on order clause.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 11, 2009
1 parent 0ab2078 commit 2503632
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/model/model.php
Expand Up @@ -1018,7 +1018,7 @@ function getColumnType($column) {
function hasField($name, $checkVirtual = false) {
if (is_array($name)) {
foreach ($name as $n) {
if ($this->hasField($n)) {
if ($this->hasField($n,$checkVirtual)) {
return $n;
}
}
Expand Down
18 changes: 18 additions & 0 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -688,6 +688,24 @@ function testPaginateSpecialType() {
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0]));
}

function testPaginateOrderVirtualField() {
$Controller =& new Controller();
$Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1';
$Controller->params['url'] = array();
$Controller->constructClasses();
$Controller->ControllerPost->virtualFields = array('offset_test' => 'ControllerPost.id + 1');

$Controller->paginate = array(
'fields' => array('id', 'title'),
'order' => 'offset_test',
'limit' => 1
);
$result = $Controller->paginate('ControllerPost');

$this->assertEqual(Set::extract($result, '{n}.ControllerPost.offset_test'), array(2, 3));
}

/**
* testDefaultPaginateParams method
*
Expand Down

0 comments on commit 2503632

Please sign in to comment.