aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/calculations.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-06-04 11:05:46 +1200
committerMichael Koziarski <michael@koziarski.com>2008-06-04 11:05:46 +1200
commite3c26e9926948587efcc8d31c729395093407df6 (patch)
tree358f418791a56620c32a48776739b4fdf39d3cb0 /activerecord/lib/active_record/calculations.rb
parentb9a9b91a3e3b892ab72ff5c618181747d6b4be04 (diff)
parent8afa725f4b98a6e0ceee4792e8ebaebb6189e5f6 (diff)
downloadrails-e3c26e9926948587efcc8d31c729395093407df6.tar.gz
rails-e3c26e9926948587efcc8d31c729395093407df6.tar.bz2
rails-e3c26e9926948587efcc8d31c729395093407df6.zip
Merge branch 'master' into patches
Diffstat (limited to 'activerecord/lib/active_record/calculations.rb')
-rw-r--r--activerecord/lib/active_record/calculations.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb
index 10e8330d1c..caa8c539d5 100644
--- a/activerecord/lib/active_record/calculations.rb
+++ b/activerecord/lib/active_record/calculations.rb
@@ -71,7 +71,7 @@ module ActiveRecord
#
# Person.sum('age')
def sum(column_name, options = {})
- calculate(:sum, column_name, options) || 0
+ calculate(:sum, column_name, options)
end
# This calculates aggregate values in the given column. Methods for count, sum, average, minimum, and maximum have been added as shortcuts.
@@ -266,6 +266,7 @@ module ActiveRecord
operation = operation.to_s.downcase
case operation
when 'count' then value.to_i
+ when 'sum' then value =~ /\./ ? value.to_f : value.to_i
when 'avg' then value && value.to_f
else column ? column.type_cast(value) : value
end