Skip to content

Fixes #7039 paginator count with instance of return 0 - #12529

Open
Si-gi wants to merge 2 commits into
doctrine:3.6.xfrom
Si-gi:fix-paginator-count-instance-of
Open

Fixes #7039 paginator count with instance of return 0#12529
Si-gi wants to merge 2 commits into
doctrine:3.6.xfrom
Si-gi:fix-paginator-count-instance-of

Conversation

@Si-gi

@Si-gi Si-gi commented Jul 7, 2026

Copy link
Copy Markdown

Fix Paginator count with INSTANCE OF parameter return 0

Fixes #7039
When a custom ResultSetMapping is set on a query, as the Paginator does for its count query, discriminator parameters recorded by the SqlWalker in the parsed RSM were ignored
A ClassMetadata bound to an INSTANCE OF expression was bound as its FQCN instead of the discriminator values, so the count was always 0.
This PR resolve discriminator parameters against the parser result's RSM, which is always populated once the query has been parsed.

I added $parsedRsm = $this->parserResult->getResultSetMapping(); in Query:resolveParameterValue() and updated the conditions on discriminatorParameters to use parsedRsm by default.
I added a test 7039 as asked by contribution guidline

Si-gi and others added 2 commits July 7, 2026 11:37
When a custom ResultSetMapping is set on a query, as the Paginator
does for its count query, the discriminator parameters recorded by
the SqlWalker in the parsed RSM were ignored: a ClassMetadata bound
to an INSTANCE OF expression was bound as its FQCN instead of the
discriminator values, so count() always returned 0 while iterating
the very same Paginator returned the expected results.

Resolve discriminator parameters against the parser result RSM,
which is always populated once the query has been parsed, keeping
the user-provided RSM as a fallback.

Fixes doctrine#7039

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant