mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
parent
3fe4b46614
commit
aa9258cbd1
2 changed files with 18 additions and 1 deletions
|
@ -2333,7 +2333,6 @@ class DboSource extends DataSource {
|
|||
if (!is_array($group)) {
|
||||
$group = array($group);
|
||||
}
|
||||
|
||||
foreach($group as $index => $key) {
|
||||
if ($model->isVirtualField($key)) {
|
||||
$group[$index] = '(' . $model->getVirtualField($key) . ')';
|
||||
|
|
|
@ -4240,5 +4240,23 @@ class DboSourceTest extends CakeTestCase {
|
|||
));
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test calculate to generate claculate statements on virtual fields
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testVirtualFieldsInGroup() {
|
||||
$this->loadFixtures('Article');
|
||||
|
||||
$Article =& ClassRegistry::init('Article');
|
||||
$Article->virtualFields = array(
|
||||
'this_year' => 'YEAR(Article.created)'
|
||||
);
|
||||
|
||||
$result = $this->db->group('this_year',$Article);
|
||||
$expected = " GROUP BY (YEAR(`Article`.`created`))";
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue