Skip to content

Commit

Permalink
Fixing issues in DboSource::group(), which always expected an optiona…
Browse files Browse the repository at this point in the history
…l argument.

Fixes #1656
  • Loading branch information
markstory committed May 21, 2011
1 parent 104f6a5 commit efbb647
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo_source.php
Expand Up @@ -2466,7 +2466,7 @@ function group($group, $model = null) {
$group = array($group);
}
foreach($group as $index => $key) {
if ($model->isVirtualField($key)) {
if (is_object($model) && $model->isVirtualField($key)) {
$group[$index] = '(' . $model->getVirtualField($key) . ')';
}
}
Expand Down
10 changes: 10 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo_source.test.php
Expand Up @@ -4555,6 +4555,16 @@ function testVirtualFieldsInGroup() {
$this->assertEqual($expected, $result);
}

/**
* Test that group works without a model
*
* @return void
*/
function testGroupNoModel() {
$result = $this->db->group('created');
$this->assertEqual(' GROUP BY created', $result);
}

/**
* test the permutations of fullTableName()
*
Expand Down

0 comments on commit efbb647

Please sign in to comment.