diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-11-10 14:16:43 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-11-10 14:16:43 -0600 |
commit | 335a31524055c7dd79618ea79b3c18d827e25d3d (patch) | |
tree | 2e024e9ef513a1e04bdf30f57dd1925129352b27 | |
parent | a6d6a1c9aca612232228c1111be810736a26ab63 (diff) | |
download | rails-335a31524055c7dd79618ea79b3c18d827e25d3d.tar.gz rails-335a31524055c7dd79618ea79b3c18d827e25d3d.tar.bz2 rails-335a31524055c7dd79618ea79b3c18d827e25d3d.zip |
Add simple case when DB calculations returns 0 instead of 0.0 [#1346 state:resolved]
-rw-r--r-- | activerecord/lib/active_record/calculations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index dd90580b3d..6f4e02b430 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -286,7 +286,7 @@ module ActiveRecord case operation when 'count' then value.to_i when 'sum' then type_cast_using_column(value || '0', column) - when 'avg' then value && value.to_f.to_d + when 'avg' then value && (value == 0 ? 0.0.to_d : value.to_d) else type_cast_using_column(value, column) end end |