mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +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)) {
|
if (!is_array($group)) {
|
||||||
$group = array($group);
|
$group = array($group);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($group as $index => $key) {
|
foreach($group as $index => $key) {
|
||||||
if ($model->isVirtualField($key)) {
|
if ($model->isVirtualField($key)) {
|
||||||
$group[$index] = '(' . $model->getVirtualField($key) . ')';
|
$group[$index] = '(' . $model->getVirtualField($key) . ')';
|
||||||
|
|
|
@ -4240,5 +4240,23 @@ class DboSourceTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$this->assertEqual($expected, $result);
|
$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