-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Mysql 5.7 requires order by clause in select DISTINCT statement (Paginator) #5622
Comments
This just means, that the mysql 5.7 s now working the same as other databases. IMO, the best fix would be to always preserve the order by. |
Yes, the preserve should stay. Here is an example of what happens.
This select fails in mysql 5.7 but when adding the last_name to the select statement it runs without any problems Working example:
|
Having the same issue after upgrading to Ubuntu 16.04. Ordering by anything other than the id, will produce this error, when using the paginator. |
I changed the code to works for me. What i changed? I added this line And i added this method
Doing this the fields in order by clause are added to select statement. I know its a poor code. So i did not create a PR. |
@diego-mazzaro I'd call that a hack rather than a solution to close this issue. It may work for you but it doesn't fix the underlying issue(s) that may cause more problems in the future. Fixing problems with hacks will lead to more hacks and unmaintainable code, which nobody likes since ORMs can be a huge PITA anyway. |
Yes @cH40z-Lord, i agree... I Just post this hack because I need my system works as it is not released a new version of Doctrine ... |
On So it will look like
|
As this obviously is an issue with invalid generated SQL, I think a bugfix is needed? (see #5930 for an example of an invalid select statement) Relaxing all SQL modes in MySQL so that even (in MySQL 5.7+) invalid SQL works without errors is no solution imho (not even temporarily). Edit: @mickadoo @ericlery instead of disabling all SQL modes, you probably only should disable the mode that is causing the problem, called |
Duplicate of #4846 |
…elect-DISTINCT-statement-(Paginator): removing extracting order by clause from the inner query
…t-DISTINCT-statement-(Paginator): fixing tests
Thanks ! This worked for me : This is a hack, but will be sufficient waiting for the PR |
…elect-DISTINCT-statement-(Paginator): removing extracting order by clause from the inner query
…t-DISTINCT-statement-(Paginator): fixing tests
copy fixed doctrine#5622 - mysql 5.7 ONLY_FULL_GROUP_BY doctrine#6143 chihiro-adachi wants to merge 2 commits into doctrine:master from chihiro-adachi:patch-1
copy fixed doctrine#5622 - mysql 5.7 ONLY_FULL_GROUP_BY doctrine#6143 chihiro-adachi wants to merge 2 commits into doctrine:master from chihiro-adachi:patch-1
Please be aware, that by setting
|
@Devolicious could you update your first message with the warning message above or link to it? People seem to be blindly using the workaround without knowing the consequences :/ Not many people will scroll down here :( |
Is there any intention to fix this issue? mySQL 5.7 has been out for > 2.5 years! The (awful) solution I'm using can be found in this gist. I tried a number of permutations of SQL modes to try to keep some data-integrity guarantees but in the end gave up - be warned that if you use the above solution you've significantly weakened mySQL's already weak protections against garbage data. |
Handled in #6143 |
Any example please to disable after postConnect in doctrine 2.5?
This still throws
And this also does not helped
and this... mysql.conf
Our query
Also tried with DQL,
Spent about 6 hours already. Using php 7.0, doctrine/dbal 2.5, docker image. Anyone clear solution? this not helped too, maybe coz docker
also trying to fix overhere by this code
does not help running this in docker mysql container does not helped
same to removing line of addOrderBy helped, but we have to sort it in passed order, like some variable $fieldName and $sortDirection Still got this cool error
also tried to add in /etc/mysql/my.conf
not helped Holly crap .
Solved the issue, because container
Because of that, container configs has
Spent about 10 hours to fix one line of that . We do not know why it is ignored. If anyone has ideas, we would be glad to hear. |
@fagacil just upgrade the ORM, really. |
thank you very much. i got the same problem too when i use mysql 8 by docker-compose. it won't work if i set the sql_mode by edit my.cnf. it should set the parm in docker-compose yml file before build container. |
Hi,
There seems to be an issue with the Paginator. In mysql 5.7 it is required to have the order by fields to be present in the select statement when using DISTINCT. I have situated where the problem at:
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L276
By preserving the order by clause as described in issue #2630 it now fails in mysql 5.7. I tested by simply adding the ordered fields to the select statement and everything worked again.
The text was updated successfully, but these errors were encountered: