Permalink
Browse files

Fixing issues in DboSource::group(), which always expected an optiona…

…l argument.


Fixes #1656
  • Loading branch information...
1 parent 104f6a5 commit efbb6479fcc5d4bb87f5a95545b1af478ac465e6 @markstory markstory committed May 21, 2011
@@ -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) . ')';
}
}
@@ -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()
*

0 comments on commit efbb647

Please sign in to comment.