-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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.5] whereHas bindings are duplicated when using $withCount #21116
Comments
@Dylan-DPC If you remove the |
Please include code in your steps of replication, including an entire laravel application in a .zip file won't help :) What code should I run in a fresh laravel project to be able to replicate? |
@themsaid I've updated the information concerning that issue and added the whole code for reproduction! |
It is better to push the repo on GH and share the link. That way people can clone it and try it directly. Works better than the zip 👍 |
You are right @Dylan-DPC 🙈 Why didn't I think of that before? 😅 |
Unfortunately i have this issue as well. Seems like this |
Description:
The QueryBuilder bindings are duplicated when using
whereHas()
while using$withCount
on the related Model. This leads to problems when using MorphToMany relations, because queries like this are created through Eloquent:Obviously, the tipable_id is "set wrong" here because the first parameter was duplicated.
Steps To Reproduce:
Setup a fresh Laravel 5.5.3 copy
Issue the commands
php artisan make:model Comment -m
php artisan make:model Post -m
andphp artisan make:model Video -m
Add the following code to the Comment model:
php artisan make:migration create_commentables_table
and add those scheme definitions:Create a new test by using
php artisan make:test HereIsTheBugTest
Use the following snippet as the test:
Don't forget to fix your database.php file (see here)
Run the test and see it fail!
Related issues
#20640
The text was updated successfully, but these errors were encountered: