diff options
author | Ken Collins <ken@metaskills.net> | 2008-11-13 10:45:57 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-11-13 10:45:57 -0600 |
commit | 57d795bad43d4a3e5eef7151099a8e40808a1031 (patch) | |
tree | 34c8b4d27c874c84eb1a5b0e24b8eb21485b425f /activerecord/lib/active_record/calculations.rb | |
parent | f857da4faf4765ad1579818d2de55f0fabb1b527 (diff) | |
download | rails-57d795bad43d4a3e5eef7151099a8e40808a1031.tar.gz rails-57d795bad43d4a3e5eef7151099a8e40808a1031.tar.bz2 rails-57d795bad43d4a3e5eef7151099a8e40808a1031.zip |
Make sure any Fixnum returned by a DB sum is type cast to a Float before standard converstion to a BigDecimal [#8994 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord/lib/active_record/calculations.rb')
-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 6f4e02b430..65512d534a 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 == 0 ? 0.0.to_d : value.to_d) + when 'avg' then value && (value.is_a?(Fixnum) ? value.to_f : value).to_d else type_cast_using_column(value, column) end end |