Add simple case when DB calculations returns 0 instead of 0.0 [#1346 state:resolved]

This commit is contained in:
Joshua Peek
2008-11-10 14:16:43 -06:00
parent a6d6a1c9ac
commit 335a315240

View File

@@ -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