Skip to content

Order paginator subqueries on raw columns for custom types - #12716

Open
GromNaN wants to merge 4 commits into
doctrine:3.8.xfrom
GromNaN:fix/paginator-custom-type-order
Open

GromNaN wants to merge 4 commits into
doctrine:3.8.xfrom
GromNaN:fix/paginator-custom-type-order

Conversation

@GromNaN

@GromNaN GromNaN commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

The paginator's identifier subquery applied the mapping type conversion to the column used by ORDER BY, so custom types with a non-reversible conversion selected the wrong page. It now orders on the stored column, while the hydration query still applies the conversion.

 SELECT DISTINCT id_0
 FROM (
     SELECT DISTINCT id_0, LENGTH(boundary_1)
     FROM (
-        SELECT g0_.id AS id_0, TRIM(g0_.boundary) AS boundary_1, g0_.label AS label_2
+        SELECT g0_.id AS id_0, g0_.boundary AS boundary_1, g0_.label AS label_2
         FROM GH5839Zone g0_
     ) dctrn_result_inner
     ORDER BY LENGTH(boundary_1) ASC
 ) dctrn_result
 LIMIT 2

Fixes #5839.

The paginator disables the PHP value conversion while generating its
identifier subquery, so ORDER BY uses the stored column instead of the
converted value. This keeps custom types with a non-reversible conversion
from selecting the wrong page.
@GromNaN GromNaN added the Bug label Oct 29, 2026
The tree walker does not add ORDER BY expressions to the SELECT list, which
MySQL rejects with DISTINCT. That is a separate pre-existing limitation.
@GromNaN
GromNaN marked this pull request as ready for review October 29, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant