Skip to content


DDC-1053: GROUP BY crashes Doctrine 2 #1643

doctrinebot opened this Issue · 4 comments

2 participants


Jira issue originally created by user dalvarez:

This query will crash Doctrine 2:

SELECT wpomOrder.documentDate
                           FROM \persistentData\model\import\webProductionOrderManager\WPOMOrder wpomOrder
                         GROUP BY wpomOrder

Here is the hard error I get:

Catchable fatal error: Argument 1 passed to Doctrine\ORM\Query\SqlWalker::walkGroupByItem() must be an instance of Doctrine\ORM\Query\AST\PathExpression, string given in /var/www/invoiceCreator/src/thirdPartyComponents/doctrine/Doctrine/ORM/Query/SqlWalker.php on line 1203

Of course, the query shown is pointless. I reduced it from a more complex statement to illustrate that it is actually the GROUP BY that breaks Doctrine. Even in a meaningful scenario with aggregates, it would not work.


Comment created by dalvarez:

The query shown above could as well be invalid, because it groups the results by something which is not in the select clause. I do not know if this should be a requirement, though, since I can think of use cases where you would want to group by something, but still not select it. Anyway, this query will work:

SELECT wpomOrder.documentDate
                           FROM \persistentData\model\import\webProductionOrderManager\WPOMOrder wpomOrder
                         GROUP BY wpomOrder.documentDate

Note that it groups the results by the expression used in the select clause rather than just the entity like in the example above.


Comment created by @beberlei:

Fixed, group by identification variable is now supported. Merged into 2.0.x

Added follow up task for 3.0 cleanup DDC-1073


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0.4 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.