mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Adding order by breaks grouped by query #6806
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Aug 16, 2021).
Hello!
I was trying to find a way to get entity result with relation count and I almost succeeded by following this post:
http://allan-simon.github.io/blog/posts/doctrine2-order-by-count-many-to-many/
The problem is that when I add order by, the query breaks and complains that some field is not in group by.
My doctrine/orm version is 2.8.1 and it seems it happened also on 2.9.3.
Is this a bug or am I missing something?
@greg0ire commented on GitHub (Aug 16, 2021):
I think you are missing something, but without the error message it will be hard to tell for sure.
@ghost commented on GitHub (Aug 17, 2021):
@greg0ire This is the beginning of the error:
SQLSTATE[42000]: Syntax error or access violation: 1055 'mytable.r0_.id' isn't in GROUP BY" at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 128 {"exception":"#0 /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(182): Doctrine\\DBAL\\Driver\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\DBAL\\Driver\\PDO\\Exception))I created simple test app here: https://github.com/mkoske/doctrine-test from the post I mentioned earlier and it seems to work just ok. I cannot get it to break. And yet, my code is almost same.
I investigated this and my code works as it should if I set
fetchJoinCollection = falseon paginator. But as soon as I set it to true, it breaks and I get this exception.@greg0ire commented on GitHub (Aug 17, 2021):
Ah so maybe you will be able to reproduce that in your test app?