-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed a problem where sum
used with a group
was not returning a Hash.
#14803
Conversation
There is already a PR for this. Could you check if it was merged? Thanks
|
@rafaelfranca It has already been merged. here it is #14773 |
Hmm. @eric-chahin, I thought you specifically checked the behaviour of Are there any other methods we should be addressing at the same time? |
Do we can close this one right?
|
@matthewd I think this was the last method in |
@rafaelfranca no; that was for |
I was under the impression that it was only |
Okay, well by my reading of https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb#L213, we're still not there... I see no reason that |
@matthewd: But these(avg/max/min) methods are not defined in the |
@matthewd Would we actually need to add those into
Unless my initial assumption was correct that |
@matthewd: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb#L83 |
@matthewd: any suggestions? |
@eric-chahin you're misreading: the preceding line is pulling a value from the hash with the key @kuldeepaggarwal well, as you point out, they're currently not defined here at all. So we don't have the problem that they're returning zero. 😄 But I don't see any reason to expect them to be missing... as far as I understand, NullRelation is intended to act just like any other relation.. so it seems those methods should in fact be here. That said, while they can all return an empty hash when grouped, they should not return zero in the ungrouped situation... the average, minimum, and maximum of an empty set is |
@matthewd Should I add those methods too? |
I'm running into this issue, is anyone still working on this? |
@matthewd any suggestions? |
@kuldeepaggarwal sorry.. yes, please add those. |
…m` used with a grouping was not returning a Hash.
@matthewd Added other aggregate methods and its test cases. |
Fixed a problem where `sum` used with a `group` was not returning a Hash.
Thanks 💚 💙 💛 💜 |
Fixed a problem where `sum` used with a `group` was not returning a Hash. Conflicts: activerecord/CHANGELOG.md
\cc @senny