mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1730: setMaxResults() does not work properly #2176
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 @doctrinebot on GitHub (Mar 28, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user nikola.petkanski:
In my understanding ORM is Object-relational mapping, so it is fare to say that setting the maximum results for a given query should return exactly this many objects mapped.
example case 1:
One would expect one Article with multiple translations attached. Unfortunately, this is not the case - you have your article, but only one translation attached.
example case 2:
In this case one would expect exactly 5 Articles to be returned with all their translations attached. Unfortunately, this might or might not be the case - depending on the order of the data returned by the database engine.
I am aware that this is because of the limit clause of the SQL, however, note that I'm setting max result to the Query object, which should have been processed by the EntityManager.
I can't think of a solution for this case, but a proper ORM should take care of such cases.
Yes, I know I can leave this one to the lazy loading and it would work, but I happened to have a case where I have multiple (>200) results and each one of them having multiple relations. In such case having a query per each entity is not an option.
@doctrinebot commented on GitHub (Mar 30, 2012):
Comment created by @beberlei:
Doctrine 2.2 has a paginator library that fixes this. In context of AbstractQuery (Native orDQL) setMaxResults() is always SQL based, never object based however.
@doctrinebot commented on GitHub (Mar 30, 2012):
Issue was closed with resolution "Won't Fix"
@aistis- commented on GitHub (Jul 18, 2017):
I guess a quick work around: