shane
2008-Dec-05 01:08 UTC
Average. Maximum. Minimum on empty Associations should also return 0 like Sum
Hi I was working with an association the other day in Rails 2.1.0 and found that using association.average(:value) returned nil when the association was empty. I found that for association.sum(:value) this was changed: http://rails.lighthouseapp.com/projects/8994/tickets/295-sum-on-associations-should-return-0-when-no-rows-are-returned So in the same manner I would like to propose that average, maximum, and minimum also return zero instead of nil when the association is empty. I have a patch and tests: http://rails.lighthouseapp.com/projects/8994/tickets/1516-average-maximum-minimum-on-associations-should-return-0-when-no-rows-are-returned This is the first time I have attempted to contribute to Rails so feedback very welcome. Cheers Shane --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---