This project is archived and is in readonly mode.
ActiveRecord::Calculations returns incorrect data when grouping by multiple fields
Reported by Alex | July 22nd, 2010 @ 11:37 PM
The :group option is broken for multiple fields when performing an AR calculation. See the example below:
Account.count(:all, :group => 'firm_id, credit_limit') # returns <OrderedHash {60=>1, 55=>1, 50=>1, 53=>1}>
The example above demonstrates that the returned hash incorrectly excludes data rows and columns. See below for the expected return value:
Account.count(:all, :group => 'firm_id, credit_limit') # should return <OrderedHash {[2, 60]=>1, [nil, 50]=>1, [9, 53]=>1, [6, 55]=>1, [1, 50]=>1, [6, 50]=>1}>
I have a attached a patch (test included) for supporting grouping by multiple fields. The behavior for grouping by a single field or an association is unchanged. Also, the :group option still takes in a string as always.
Comments and changes to this ticket
-
Alex July 22nd, 2010 @ 11:45 PM
- Tag set to 2.x
-
Alex July 26th, 2010 @ 07:53 PM
- Tag changed from 2.x to 2.3.x, 2.x, calculations, patch
-
Jeff Kreeftmeijer November 8th, 2010 @ 08:53 AM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
-
Alex November 18th, 2010 @ 06:39 PM
This has been resolved, see #497 https://rails.lighthouseapp.com/projects/8994/tickets/497-activerec...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>