-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DDC-3661: Doctrine\ORM\LazyCriteriaCollection unpredictable count() #4491
Comments
Comment created by @Ocramius: This is indeed a bug: consider writing an example test case so that we can work on it. |
Comment created by fedikw: I think I found solution, I try make pull request tomorrow |
Comment created by fedikw: there it is #1372 -For exaple can take that docs.doctrine-project.org/en/latest/reference/working-with-associations.html#filtering-collections- For example for User entity:
|
Comment created by @doctrinebot: |
This bug just bit me, too. IMO, this query should take LIMIT & OFFSET into consideration, if set. |
Related bug that caused inappropriate behavior: doctrine/orm#4491
Related bug that caused inappropriate behavior: doctrine/orm#4491
Five years ago in a galaxy far, far away someone invented a LazyCriteriaCollection #882. I wish the behavior to be documented somehow, at least here. It could have saved some hours debugging. |
Jira issue originally created by user fedikw:
When criteria has set $maxResults Doctrine\ORM\LazyCriteriaCollection::count() can return different result depend when it was called, before initialize() or after.
When LazyCriteriaCollection not initialized then count() return Total from database,
when LazyCriteriaCollection have been initialized then count() return Total from "collection" that is limited by Criteria::$maxResults.
Example you have 30 items in database and Criteria::$maxResults = 5, then:
It is very confuse ;)
also I not sure which behaviour is right: it should always return Total from database or Total depend from Criteria::$maxResults
The text was updated successfully, but these errors were encountered: