-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
group function accurate? #19
Labels
bug
Something isn't working
Comments
Dear @duclet , Thanks for the very complete bug report. I just submitted a PR that update the behavior of the Group operation. Do you mind having a look at it and maybe try it to see if it fits now ? |
drupol
added a commit
that referenced
this issue
Aug 26, 2020
PR has been merged closing the issue. |
drupol
added a commit
that referenced
this issue
Aug 27, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps required to reproduce the problem
[['id' => 1, 'name' => 'A'], ['id' => 2, 'name' => 'B'], ['id' => 1, 'name' => 'C']]
Collection::with(arr)->groupBy(function($k, $v) { return $v['id']; })->all()
Expected Result
[ 1 => [ ['id' => 1, 'name' => 'A'], ['id' => 1, 'name' => 'C'] ], 2 => [ ['id' => 2, 'name' => 'B'] ] ]
Actual Result
[ 1 => [ ['id' => 1, 'name' => 'A', [ 0 => ['id' => 1, 'name' => 'C'] ] ], 2 => [ ['id' => 2, 'name' => 'B'] ] ]
Maybe my understanding of what the group function is supposed to do is incorrect by I was thinking it is more in line with what I expect the result to be. The problem seems to be that first time value is set, it is set as is. Second time, it is converted to array and then appended which cause the behavior above. So that means right now, the above would only work for simple values and not arrays or objects.
The text was updated successfully, but these errors were encountered: