[PR #1353] Paginator fixes take3 #9415

Closed
opened 2026-01-22 16:04:15 +01:00 by admin · 0 comments
Owner

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

State: closed
Merged: No


This PR fixes issues reported in #1347 and #1351.

  • Ordering a query by a column from an association which uses SINGLE_TABLE inheritance no longer throws an error.
  • Limiting a query which is ordered by fields from a joined -To-Many association now works as expected.

This patch converts LimitSubqueryOutputWalker to use the ROW_NUMBER window function for queries on platforms that support it. Other platforms use a modified version of the previous method. The modification is to not select the ORDER BY columns in the wrapping query. The reason those columns were selected like that in the first place is that ORDER BY on columns not in the select list is unsupported on many platforms. MySQL and SQLite are fine with it, and don't support ROW_NUMBER.

The ROW_NUMBER solution is actually much simpler.

LimitSubqueryOutputWalker SQL generation tests for PG and Oracle have been changed.

There are 2 failing expectedException tests right now. The LimitSubqueryWalker needs to be modified to throw an exception when it detects a query that does the following things together:

  • Joins a -To-Many association
  • Orders by a column from the associated entity
  • Limits the result

As with the previous patch, this depends on changes to SQLServerPlatform2008 that have not yet been merged. SQLServerPlatform2008 in DBAL/master currently mangles the generated queries when trying to apply LIMIT/OFFSET.

**Original Pull Request:** https://github.com/doctrine/orm/pull/1353 **State:** closed **Merged:** No --- This PR fixes issues reported in #1347 and #1351. - Ordering a query by a column from an association which uses SINGLE_TABLE inheritance no longer throws an error. - Limiting a query which is ordered by fields from a joined -To-Many association now works as expected. This patch converts LimitSubqueryOutputWalker to use the ROW_NUMBER window function for queries on platforms that support it. Other platforms use a modified version of the previous method. The modification is to not select the ORDER BY columns in the wrapping query. The reason those columns were selected like that in the first place is that ORDER BY on columns not in the select list is unsupported on many platforms. MySQL and SQLite are fine with it, and don't support ROW_NUMBER. The ROW_NUMBER solution is actually much simpler. LimitSubqueryOutputWalker SQL generation tests for PG and Oracle have been changed. **There are 2 failing expectedException tests right now.** The LimitSubqueryWalker needs to be modified to throw an exception when it detects a query that does the following things together: - Joins a -To-Many association - Orders by a column from the associated entity - Limits the result As with the previous patch, this depends on changes to SQLServerPlatform2008 that have not yet been merged. SQLServerPlatform2008 in DBAL/master currently mangles the generated queries when trying to apply LIMIT/OFFSET.
admin added the pull-request label 2026-01-22 16:04:15 +01:00
admin closed this issue 2026-01-22 16:04:15 +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#9415