Skip to content

Preserve subselect nesting in LimitSubqueryOutputWalker - #12715

Open
GromNaN wants to merge 3 commits into
doctrine:3.8.xfrom
GromNaN:fix/paginator-nested-subselect
Open

GromNaN wants to merge 3 commits into
doctrine:3.8.xfrom
GromNaN:fix/paginator-nested-subselect

Conversation

@GromNaN

@GromNaN GromNaN commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

walkSubSelect() restored $inSubSelect to false unconditionally, so a nested subselect cleared the flag while the outer one was still being walked. The path expressions that followed were recorded as ORDER BY expressions and added to the outer SELECT, including aliases that only exist inside the IN subselect. The query failed with Unknown column 'c1_.id' in 'field list'.

The flag now restores its previous value.

Before:

SELECT p0_.id AS id_0, c1_.id AS id_1, c1_.name AS name_2, c1_.rank AS rank_3,
       c2_.id AS id_4, c2_.name AS name_5, c2_.rank AS rank_6,
       c1_.parent_id AS parent_id_7, c2_.parent_id AS parent_id_8

After:

SELECT p0_.id AS id_0, c1_.id AS id_1, c1_.name AS name_2, c1_.rank AS rank_3,
       c1_.parent_id AS parent_id_4

The extra c1_ columns in the first block come from the IN subselect. They no longer leak into the outer SELECT.

Fixes #12697.

Nested subselects reset the inSubSelect flag while the outer one is still
being walked, which leaked their path expressions into the paginator SELECT.
rank is a reserved word in MySQL 8, so the fixture insert failed.
@GromNaN GromNaN added the Bug label Oct 29, 2026
…ager

Use try/finally in walkSubSelect and clear the EntityManager after the
fixture flush.
@GromNaN
GromNaN marked this pull request as ready for review October 29, 2026 23:44
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.

1 participant