mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3193: Paginator hydrating the iterator with only half the limit #3958
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 (Jun 26, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user alanhartless:
When using paginator on a left join for a one to many association, Doctrine is only hydrating half the requested results via the limit set by setMaxResults(). It is giving the correct total as indicated by count() but getIterator() is only returning half the requested results.
For example, I have 82 results, with a setMaxResults(50), getIterator() only has 25 hydrated!
My entities are:
Submission
/****
* @ORM\OneToMany(targetEntity="Result", mappedBy="submission", cascade={"persist", "remove", "refresh", "detach"})
*/
private $results;
Result
And I'm using the following query builder in the submission repository:
$q = $this->createQueryBuilder('s')
->select('s, r')
->leftJoin('s.results', 'r')
->setFirstResult(0)
->setMaxResults(0);
It seems to be counting each submissions result as one rather than each submission. So it is returning 50, although its 50 results within 25 submissions. I need to find a way to get it to return 50 submissions instead. Maybe I'm doing something wrong?