[PR #7581] Fix LimitSubqueryOutputWalker : Add default order by to sql wrapper if not set. #10554

Open
opened 2026-01-22 16:07:56 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/7581

State: closed
Merged: No


I got a problem when testing a huge volume of data : greater than offset (of the order of 450000), the query by range returns always the same row (the last one in the list).
Exemple of query :
SELECT distinct id_0 FROM (SELECT o0_.id AS id_0 FROM myTable o0_) dctrn_result LIMIT 1 OFFSET 450001
reeturns same row of :
SELECT distinct id_0 FROM (SELECT o0_.id AS id_0 FROM myTable o0_) dctrn_result LIMIT 1 OFFSET 450100

Because mysql is not able to assign a default row_num to results, the solution is to define a default order by in wrap query.
Result :
SELECT distinct id_0 FROM (SELECT o0_.id AS id_0 FROM myTable o0_) dctrn_result order by id_0 ASC LIMIT 1 OFFSET 450001

Hope it helps..

**Original Pull Request:** https://github.com/doctrine/orm/pull/7581 **State:** closed **Merged:** No --- I got a problem when testing a huge volume of data : greater than offset (of the order of 450000), the query by range returns always the same row (the last one in the list). Exemple of query : `SELECT distinct id_0 FROM (SELECT o0_.id AS id_0 FROM myTable o0_) dctrn_result LIMIT 1 OFFSET 450001` reeturns same row of : `SELECT distinct id_0 FROM (SELECT o0_.id AS id_0 FROM myTable o0_) dctrn_result LIMIT 1 OFFSET 450100` Because mysql is not able to assign a default row_num to results, the solution is to define a default `order by` in wrap query. Result : `SELECT distinct id_0 FROM (SELECT o0_.id AS id_0 FROM myTable o0_) dctrn_result order by id_0 ASC LIMIT 1 OFFSET 450001` Hope it helps..
admin added the pull-request label 2026-01-22 16:07:56 +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#10554