DDC-2954: Paginator loses items #3677

Open
opened 2026-01-22 14:25:09 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 5, 2014).

Originally assigned to: @beberlei on GitHub.

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 col_with_id, order_by_column (...) ORDER BY order_by_column".
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.

Originally created by @doctrinebot on GitHub (Feb 5, 2014). Originally assigned to: @beberlei on GitHub. 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 col_with_id, order_by_column (...) ORDER BY order_by_column". 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.
admin added the Bug label 2026-01-22 14:25:09 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 5, 2014):

Comment created by @ocramius:

[~mariusz.jaskolka] this needs more details

@doctrinebot commented on GitHub (Feb 5, 2014): Comment created by @ocramius: [~mariusz.jaskolka] this needs more details
Author
Owner

@doctrinebot commented on GitHub (Feb 6, 2014):

Comment created by mariusz.jaskolka:

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

@doctrinebot commented on GitHub (Feb 6, 2014): Comment created by mariusz.jaskolka: OK, I will try to find out where the problem is.
Author
Owner

@doctrinebot commented on GitHub (Feb 6, 2014):

Comment created by mariusz.jaskolka:

I have edited description, maybe additional information will help.

@doctrinebot commented on GitHub (Feb 6, 2014): Comment created by mariusz.jaskolka: I have edited description, maybe additional information will help.
Author
Owner

@doctrinebot commented on GitHub (Feb 7, 2014):

Comment created by mariusz.jaskolka:

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

@doctrinebot commented on GitHub (Feb 7, 2014): Comment created by mariusz.jaskolka: I send the bugfix in attachment. I will describe it soon.
Author
Owner

@doctrinebot commented on GitHub (Feb 7, 2014):

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 commented on GitHub (Feb 7, 2014): 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.
Author
Owner

@doctrinebot commented on GitHub (Feb 11, 2014):

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

@doctrinebot commented on GitHub (Feb 11, 2014): 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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3677