rails/rails — pull request #7439 by refractalize (2012-08-24 09:34:30+00:00)
Title: ActiveRecord: sum expression returns string '0' for no records, fixed

The bug:

Account.where('1 = 2').sum("2 * credit_limit") => '0'

That is, sum with an expression (not a column name) on a condition or collection that returns no records returns the string "0", whereas it should return an integer, 0.