Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Relation count on list view with mysql strict_mode enabled results in an error #5134
Comments
|
@Klaasie feel free to port the linked PR to the October Rain library as a PR (including the tests if possible). |
|
This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. |
|
This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. |


Description:
For one of our plugins we're currently running into the error described below:
The query in question:
The issue is the result of a combination using count on a model with the sortable trait (which will add sorting through a global scope) and the mysql strict setting being true.
I've traced the issue back to the
withCountmethod insrc/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php. So it's an issue in Laravel.Digging further I've noticed that this issue has actually been resolved in 7.x with this pull request: https://github.com/laravel/framework/pull/29925/files
In 6.x however this has not been fixed.
Additionally: withCount seems to add a model.* to the query, the list widget adds another model.* to the select at the end of the method. It's a bit weird but this does not cause any issues.
Steps To Reproduce:
Apply
'strict' => true,to the mysql database configuration throughdatabase.php.Create a plugin with 2 models and a controller with list view.
Model 1 has many Model 2.
Model 2 has sortable trait.
Model 1 columns shows count of model 2 relations.
Visit the list view page and see an error.