Jira issue originally created by user mariusz.jaskolka:
Sometimes when when I use Paginator (Doctrine\ORM\Tools\Pagination\Paginator)
there are too few items in result (no, it is not the end of list). There two situations:
1. I have four items on page 1 and two items on page 2 (pageLimit is 5). It is no so bad
2. I have four items on page 1 and there is no page 2 (while there should be 5 all items). This is very bad because I lose one item.
In function Paginator::getIterator there is variable $ids. In my situation it contains five numbers [34,26,34,15,12]. There is duplicated value 34 but ids of top-level entities should be distinct (as far as we do not use CROSS JOIN, or maybe I am wrong).
The Paginator::count function works correctly, it does not count duplicated values twice.
Statement that gets $ids is like following:
SELECT a.* FROM (SELECT DISTINCT ID2, BEGINTIME70 FROM (...) dctrn_result ORDER BY BEGINTIME70 DESC) a WHERE ROWNUM <= 5
EDIT 2 - Bugfix description:
The result items of the query is not unique because of
"SELECT DISTINCT colwith_id, order_by_column (...) ORDER BY order_bycolumn".
If we had items like following:
After DISTINCT operation the result would be:
But we want to have unique firs column, not pairs. That's why we should do "ORDER BY" before "DISTINCT" - not in the same time.
Please confirm if the solution is correct.
Comment created by @ocramius:
[~mariusz.jaskolka] this needs more details
Comment created by mariusz.jaskolka:
OK, I will try to find out where the problem is.
I have edited description, maybe additional information will help.
I send the bugfix in attachment. I will describe it soon.
Bugfix version 2 - previously I did not notice that oracle loses order after DISTINCT operation. Thus I used GROUP BY.
I do not know if I can change status of this issue from "Awaiting Feedback". I can not see such option :D