Permalink
Browse files

Working on virtual fields on order clause.

  • Loading branch information...
1 parent 0ab2078 commit 25036323278c65e53b04df9ad38d3c42c0bf9915 @lorenzo lorenzo committed Nov 12, 2009
Showing with 19 additions and 1 deletion.
  1. +1 −1 cake/libs/model/model.php
  2. +18 −0 cake/tests/cases/libs/controller/controller.test.php
@@ -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;
}
}
@@ -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
*

0 comments on commit 2503632

Please sign in to comment.