I remember a long time ago I had a patch for average that would trust what the DB returned, in my case integers.
https://github.com/rails/rails/commit/95d5d9b6c48c08f1fba0c77ecbc97b62b2603824 It would be nice if calculations could always rely on the raw_connection to return data types converted to ruby primitives correctly. Not sure if that '0' should be a 0 or not, maybe be helpful to see what fails if changed? - Ken On Jan 11, 2012, at 4:01 PM, alex wrote: > Just bumped into this. It's on line 323 now: > https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb#L323 > > I tried to go a way back like beginning of 2010 and it was still there. Not > sure why a sum() would return a String, true. I currently converting it to > Float (my case) with ...sum(:column_name).to_f -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
