Skip to content

Commit

Permalink
Issue 92 aggregate functions always returning ints
Browse files Browse the repository at this point in the history
  • Loading branch information
treffynnon committed Jan 11, 2013
1 parent 2c16789 commit f4b107c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Changelog
* Fix when using `set_expr` alone it doesn't trigger query creation - closes issue #90
* Escape quote symbols in "_quote_identifier_part" - close issue #74
* Add HAVING clause functionality
* Fix issue with aggregate functions always returning `int` when is `float` sometimes required - closes issue #92

#### 1.2.3 - release 2012-11-28

Expand Down
11 changes: 10 additions & 1 deletion idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,16 @@ protected function _call_aggregate_db_function($sql_function, $column) {
}
$this->select_expr("$sql_function($column)", $alias);
$result = $this->find_one();
return ($result !== false && isset($result->$alias)) ? (int) $result->$alias : 0;

$return_value = 0;
if($result !== false && isset($result->$alias)) {
if((int) $result->$alias == (float) $result->$alias) {
$return_value = (int) $result->$alias;
} else {
$return_value = (float) $result->$alias;
}
}
return $return_value;
}

/**
Expand Down

0 comments on commit f4b107c

Please sign in to comment.