mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Paginator adds columns of joined entity to SELECT clause #7549
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 @janopae on GitHub (Sep 12, 2025).
Bug Report
Summary
When joining a relation without adding it to the SELECT, Paginator goes and adds all fields from the relation to the SELECT. This causes breakage to some queries.
Current behavior
Take a look at the following QueryBuilder:
I join the relation
product.purchasewithout selecting any fields from it. This is important, because selecting fields (outside of an aggregate function) would break the group by statement (at least on MySQL).The problem is: As soon as the Paginator steps in (
foreach(new Paginator($queryBuilder) {}), all fields from the joined relation get added to the SELECT, leading to the following MySQL error:Is that necessary? If not, we should avoid this.
Expected behavior
I'd prefer the Paginator to understand that these fields should not be part of the result and not add them to the SELECT. But I know the internals of the Paginator too little to know if this is possible, or if the Paginator needs those fields for some of the magic it's doing.
How to reproduce
TODO
@janopae commented on GitHub (Sep 12, 2025):
I just found out the problem disappears when I construct the Paginator with
new Paginator($queryBuilder, fetchJoinCollection: false).The docs under https://www.doctrine-project.org/projects/doctrine-orm/en/3.5/tutorials/pagination.html suggest that Doctine developers hope to automate this in the future.
So this issue can probably be closed?