mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 01:13:14 +02:00
groupBY with entity root DQL alias is missing discriminator field #7375
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 @kshtompel on GitHub (May 16, 2024).
Bug Report
While using groupBy(ROOT_DQL_ALIAS) for aggregated query resulted SQL with missing discriminator field and this is leading to
[42803] ERROR: column "p0_.type" must appear in the GROUP BY clause or be used in an aggregate function
Summary
Suggestion to fix
Current behavior
No discriminator field added to GROUP BY clause
How to reproduce
Create aggregated query with group by entity identification alias and entity has discriminator field.
As a result there is no discriminator field in the resulted SQL GROUP BY clause
Expected behavior
All the columns should appear in the SQL GROUP BY clause for aggregated queries
@kshtompel commented on GitHub (May 16, 2024):
Currently can be tackled with inheritance from the base SqlWalker and overriding
public function walkGroupByItem($groupByItem): stringmethodbut all the checks from parent should be covered for instance: if $groupByItem is not path_expression, not returning variable, etc..