DDC-3606: [GH-1325] fixed PostgreSQL and Oracle pagination issues #4429

Closed
opened 2026-01-22 14:41:27 +01:00 by admin · 8 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 9, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of vaheshadunts:

Url: https://github.com/doctrine/doctrine2/pull/1325

Message:

Pagination with ordering on 1:m and m:m relations, was not working
properly because of selecting the ordered fields in main select
statement with distinction (e.g. SELECT DISTINCT e0_.id, p1_.name from
... ) in this case we've received less rows than we've required in
query. So I've modified the subquery generation part.
In case of PostgreSQL and Oracle added the row_number in the subquery
over order by statement, then the main select is grouped by id and
selected min of row number, also ordering by rownumber asc, because they
are on right order already (e.g. select e0_.id, min(rownum) as rownum
from ..... order by rownum).
In case of MySQL, the subselect result with ids are in right order so
there is no need to select that fields(this fixes the same issue too)
In other cases I haven't tested because of that leaved the same.

Originally created by @doctrinebot on GitHub (Mar 9, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of vaheshadunts: Url: https://github.com/doctrine/doctrine2/pull/1325 Message: Pagination with ordering on 1:m and m:m relations, was not working properly because of selecting the ordered fields in main select statement with distinction (e.g. SELECT DISTINCT e0_.id, p1_.name from ... ) in this case we've received less rows than we've required in query. So I've modified the subquery generation part. In case of PostgreSQL and Oracle added the row_number in the subquery over order by statement, then the main select is grouped by id and selected min of row number, also ordering by rownumber asc, because they are on right order already (e.g. select e0_.id, min(rownum) as rownum from ..... order by rownum). In case of MySQL, the subselect result with ids are in right order so there is no need to select that fields(this fixes the same issue too) In other cases I haven't tested because of that leaved the same.
admin added the Bug label 2026-01-22 14:41:27 +01:00
admin closed this issue 2026-01-22 14:41:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 9, 2015):

@doctrinebot commented on GitHub (Mar 9, 2015): - depends on [DDC-3623: [GH-1337] Paginator OrderBy fix take 2](http://www.doctrine-project.org/jira/browse/DDC-3623) - depends on [DDC-3629: [GH-1342] Paginator functional tests](http://www.doctrine-project.org/jira/browse/DDC-3629)
Author
Owner

@doctrinebot commented on GitHub (Mar 9, 2015):

Comment created by vaheshadunts:

Hi Benjamin Eberlei, please let me know if I need to change something, I've used regular expression to change the doctrine's generated select statement, if there is a better way please let me know.

The code I've modified
https://github.com/vaheshadunts/doctrine2/blob/DDC-1958/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L221

@doctrinebot commented on GitHub (Mar 9, 2015): Comment created by vaheshadunts: Hi Benjamin Eberlei, please let me know if I need to change something, I've used regular expression to change the doctrine's generated select statement, if there is a better way please let me know. The code I've modified https://github.com/vaheshadunts/doctrine2/blob/[DDC-1958](http://www.doctrine-project.org/jira/browse/DDC-1958)/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L221
Author
Owner

@doctrinebot commented on GitHub (Mar 9, 2015):

Comment created by vaheshadunts:

Also please let me know should I have to modify the test assertions of the queries which are have changed by my modifications? Or I have to skip the continuous integration ?

@doctrinebot commented on GitHub (Mar 9, 2015): Comment created by vaheshadunts: Also please let me know should I have to modify the test assertions of the queries which are have changed by my modifications? Or I have to skip the continuous integration ?
Author
Owner

@doctrinebot commented on GitHub (Mar 16, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1325] was labeled:
https://github.com/doctrine/doctrine2/pull/1325

@doctrinebot commented on GitHub (Mar 16, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1325] was labeled: https://github.com/doctrine/doctrine2/pull/1325
Author
Owner

@doctrinebot commented on GitHub (Mar 16, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1325] was labeled:
https://github.com/doctrine/doctrine2/pull/1325

@doctrinebot commented on GitHub (Mar 16, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1325] was labeled: https://github.com/doctrine/doctrine2/pull/1325
Author
Owner

@doctrinebot commented on GitHub (Mar 24, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1325] was assigned:
https://github.com/doctrine/doctrine2/pull/1325

@doctrinebot commented on GitHub (Mar 24, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1325] was assigned: https://github.com/doctrine/doctrine2/pull/1325
Author
Owner

@doctrinebot commented on GitHub (Mar 24, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1325] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1325

@doctrinebot commented on GitHub (Mar 24, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1325] was unlabeled: https://github.com/doctrine/doctrine2/pull/1325
Author
Owner

@doctrinebot commented on GitHub (Mar 24, 2015):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 24, 2015): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4429