Skip to content
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

[5.3] fix withCount aliasing problem #16853

Merged
merged 1 commit into from
Dec 19, 2016
Merged

[5.3] fix withCount aliasing problem #16853

merged 1 commit into from
Dec 19, 2016

Conversation

moritz-h
Copy link
Contributor

Using withCount with multiple tables and the aliasing feature only for the first entry leads to wrong result names.
$model->withCount(['foo as foo_bar', 'foo']);

Error is here:
https://github.com/laravel/framework/blob/5.3/src/Illuminate/Database/Eloquent/Builder.php#L1112
The code is in an foreach loop so isset($alias) is also true when the last loop set the alias but the current loop does not us an alias. So the name from the last loop is reused instead of the default name.

@taylorotwell taylorotwell merged commit 2b26ede into laravel:5.3 Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants