DDC-3598: Paginator incorrect ordering #4422

Open
opened 2026-01-22 14:41:19 +01:00 by admin · 0 comments
Owner

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

Originally assigned to: @deeky666 on GitHub.

Jira issue originally created by user harmar:

When ordering by multiple fields, with the order by fields not contained in the original select statement the paginator outputs in an incorrect order.
I found the issue is in the LimitSubqueryOutputWalker in the preserveSqlOrdering function. This is the query it generates

SELECT DISTINCT id1, date*added3 FROM (SELECT t0_.description AS description0, t0_.id AS id1, t0_.date AS date2, t0_.date_added AS date_added3 FROM Ticket t0_ INNER JOIN user u1_ ON t0_.assigned_user_id = u1_.id INNER JOIN user u2_ ON t0_.created_user_id = u2_.id WHERE t0_.project_id = ? ORDER BY u2_.first_name DESC, t0_.date_added DESC) dctrn_result ORDER BY date*added3 DESC

So it appears that it ignores any order by field that is not included in the inner select statement.

Originally created by @doctrinebot on GitHub (Mar 3, 2015). Originally assigned to: @deeky666 on GitHub. Jira issue originally created by user harmar: When ordering by multiple fields, with the order by fields not contained in the original select statement the paginator outputs in an incorrect order. I found the issue is in the LimitSubqueryOutputWalker in the preserveSqlOrdering function. This is the query it generates ``` SELECT DISTINCT id1, date*added3 FROM (SELECT t0_.description AS description0, t0_.id AS id1, t0_.date AS date2, t0_.date_added AS date_added3 FROM Ticket t0_ INNER JOIN user u1_ ON t0_.assigned_user_id = u1_.id INNER JOIN user u2_ ON t0_.created_user_id = u2_.id WHERE t0_.project_id = ? ORDER BY u2_.first_name DESC, t0_.date_added DESC) dctrn_result ORDER BY date*added3 DESC ``` So it appears that it ignores any order by field that is not included in the inner select statement.
admin added the Bug label 2026-01-22 14:41:19 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4422