aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-10-15 14:44:10 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-10-15 14:44:10 -0700
commit0a78417386958e849a32e3b8def23e3e28f1e5b0 (patch)
treecbafbce249130e46f42b7ba590173dbe4c75403d /activerecord/lib
parent081f0ad413cd821f8dad5b334e7479ffdc0b037d (diff)
parent51d6e21c966362ed63318d216913bcef504833a4 (diff)
downloadrails-0a78417386958e849a32e3b8def23e3e28f1e5b0.tar.gz
rails-0a78417386958e849a32e3b8def23e3e28f1e5b0.tar.bz2
rails-0a78417386958e849a32e3b8def23e3e28f1e5b0.zip
Merge pull request #7439 from featurist/master
ActiveRecord: sum expression returns string '0' for no records, fixed
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 7c43d844d0..6317004631 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -349,7 +349,7 @@ module ActiveRecord
def type_cast_calculated_value(value, column, operation = nil)
case operation
when 'count' then value.to_i
- when 'sum' then type_cast_using_column(value || '0', column)
+ when 'sum' then type_cast_using_column(value || 0, column)
when 'average' then value.respond_to?(:to_d) ? value.to_d : value
else type_cast_using_column(value, column)
end