mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Paginator count returns zero when using instance of #5875
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 @pedrobrost on GitHub (Feb 5, 2018).
I have a query with something like this:
It works perfectly when I iterate over the paginator, the results are correct, but the
countresult is always zero:This only happens when I use
INSTANCE OF. I'm using single table inheritance.@Ocramius commented on GitHub (Feb 5, 2018):
Can you check the generated SQL?
@pedrobrost commented on GitHub (Feb 5, 2018):
@Ocramius commented on GitHub (Feb 5, 2018):
And what if you iterate over results? What is the query? Are there results at all?
@Ocramius commented on GitHub (Feb 5, 2018):
Overall, this looks like an issue in inheritance and criteria applied to it, but we'd need to have a failing test case to attack it. Can you please see if writing one similar to the ones in https://github.com/doctrine/doctrine2/tree/master/tests/Doctrine/Tests/ORM/Functional/Ticket is feasible on your end?
@pedrobrost commented on GitHub (Feb 5, 2018):
If I iterate over results I get all as expected, the
countis the only problem. I will see how to write one of that tests, first time ;)I'd like to mention this:
In
Doctrine\ORM\Tools\Paginationclass, ingetCountQuery()if I replace this:for only this:
It works perfectly (I don't understand what is happening).
Thanks, and sorry for my english, I will see how to create the test
@Ocramius commented on GitHub (Feb 5, 2018):
@pedrobrost that at least isolates the bug to
Doctrine\ORM\Tools\Pagination\CountOutputWalkerAlso, make sure you try your test against
2.6andmaster:-)@pedrobrost commented on GitHub (Feb 5, 2018):
I have not done the test yet, but I think the problem is setting the parameter, as @eheuje says here, if we set the parameter using
getClassMetadata(), thecountquery won't work.@sdespont commented on GitHub (May 2, 2018):
This problem still exists in version 2.6.1
@jerkan commented on GitHub (Nov 21, 2018):
I found a workaround using queryBuilder expr method:
->where($queryBuilder->expr()->isInstanceOf('alias', Classname::class))@xAzoom commented on GitHub (Aug 23, 2022):
This problem still exists :/