Skip to content

Commit

Permalink
Add simple case when DB calculations returns 0 instead of 0.0 [#1346
Browse files Browse the repository at this point in the history
…state:resolved]
  • Loading branch information
josh committed Nov 10, 2008
1 parent a6d6a1c commit 335a315
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/calculations.rb
Expand Up @@ -286,7 +286,7 @@ 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 '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
Expand Down

0 comments on commit 335a315

Please sign in to comment.