Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone query hints and parameters in LimitSubqueryOutputWalker constructor #11826

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

aprat84
Copy link
Contributor

@aprat84 aprat84 commented Feb 5, 2025

Fixes #11741

Should be merged up to at least v2.20.0 and v3.3.0.

The problem seems to be that LimitSubqueryOutputWalker clones the Query object, but not its hints (including the fetchMode hint, which causes the issue).
Don't know if cloning the parameters is really needed.
Been inspired on what the class Paginator does when cloning a Query.
Suggestions are welcome!

@aprat84 aprat84 force-pushed the gh-11741 branch 2 times, most recently from 2ebf558 to 52b1cdb Compare February 6, 2025 09:45
…ctor

This fixes a bug that arises when using Pagination and an entity relation is mapped with fetch-mode EAGER but setFetchMode LAZY (or anything that is not EAGER) has been used on the query. If the query use WITH condition, an exception is incorrectly raised (Associations with fetch-mode=EAGER may not be using WITH conditions).
The class LimitSubqueryOutputWalker clones the query, but not its parameters and hints, so the generated subquery does not know that fetch-mode has been overridden.

Fixes doctrine#11741
@greg0ire greg0ire added the Bug label Feb 12, 2025
@greg0ire greg0ire added this to the 2.20.3 milestone Feb 12, 2025
@greg0ire greg0ire merged commit 2c2ef65 into doctrine:2.20.x Feb 12, 2025
74 checks passed
@greg0ire
Copy link
Member

Thanks @aprat84 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants