DDC-1053: GROUP BY crashes Doctrine 2 #1311

Closed
opened 2026-01-22 13:09:54 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 1, 2011).

Originally assigned to: @beberlei on GitHub.

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.

Originally created by @doctrinebot on GitHub (Mar 1, 2011). Originally assigned to: @beberlei on GitHub. 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.
admin added the Bug label 2026-01-22 13:09:54 +01:00
admin closed this issue 2026-01-22 13:09:55 +01:00
Author
Owner
@doctrinebot commented on GitHub (Mar 1, 2011): - relates to [DDC-1073: Refactor SqlWalker::walkGroupByItem not to use PathExpression anymore but accept strings (identification variable) aswell](http://www.doctrine-project.org/jira/browse/DDC-1073)
Author
Owner

@doctrinebot commented on GitHub (Mar 1, 2011):

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.

@doctrinebot commented on GitHub (Mar 1, 2011): 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.
Author
Owner

@doctrinebot commented on GitHub (Mar 20, 2011):

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

@doctrinebot commented on GitHub (Mar 20, 2011): 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](http://www.doctrine-project.org/jira/browse/DDC-1073)
Author
Owner

@doctrinebot commented on GitHub (Mar 20, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 20, 2011): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1311