Skip to content

Loading…

DDC-2954: Paginator loses items #3717

Open
doctrinebot opened this Issue · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user mariusz.jaskolka:

Sometimes when when I use Paginator (Doctrine\ORM\Tools\Pagination\Paginator)

  • with query contains orderBy
  • with $fetchJoinCollection = true
  • lot of joins with toMany associations

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.


EDIT:
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:
(1,A)
(1,B)
(1,B)
(2,C)

After DISTINCT operation the result would be:
(1,A)
(1,B)
(2,C)

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.

@doctrinebot

Comment created by @ocramius:

[~mariusz.jaskolka] this needs more details

@doctrinebot

Comment created by mariusz.jaskolka:

OK, I will try to find out where the problem is.

@doctrinebot

Comment created by mariusz.jaskolka:

I have edited description, maybe additional information will help.

@doctrinebot

Comment created by mariusz.jaskolka:

I send the bugfix in attachment. I will describe it soon.

@doctrinebot

Comment created by mariusz.jaskolka:

Bugfix version 2 - previously I did not notice that oracle loses order after DISTINCT operation. Thus I used GROUP BY.

@doctrinebot

Comment created by mariusz.jaskolka:

I do not know if I can change status of this issue from "Awaiting Feedback". I can not see such option :D

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.