mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
If average value from DB is 0, make sure to convert it to a 0.0 float before calling #to_d on it [#1346 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
1767c4b2da
commit
a7f920f674
1 changed files with 1 additions and 1 deletions
|
@ -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_d
|
||||
when 'avg' then value && value.to_f.to_d
|
||||
else type_cast_using_column(value, column)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue