Permalink
Browse files

Only check for existing method expresion() when it actually will be c…

…alled.

Datasources that use calculate() should not be forced to implement expression() as well
  • Loading branch information...
1 parent 8c631fa commit 30268f6a081323e67dfa28420d8165ea9c6b0ab6 @ceeram ceeram committed Apr 5, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Cake/Model/Model.php
View
@@ -2749,12 +2749,12 @@ protected function _findCount($state, $query, $results = array()) {
if ($state === 'before') {
$db = $this->getDataSource();
$query['order'] = false;
- if (!method_exists($db, 'calculate') || !method_exists($db, 'expression')) {
+ if (!method_exists($db, 'calculate')) {
return $query;
}
if (empty($query['fields'])) {
$query['fields'] = $db->calculate($this, 'count');
- } elseif (is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) {
+ } elseif (method_exists($db, 'expression') && is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) {
$query['fields'] = $db->calculate($this, 'count', array(
$db->expression($query['fields']), 'count'
));

0 comments on commit 30268f6

Please sign in to comment.