DDC-3434: LimitSubqueryOutputWalker does not retain correct ORDER BY expression fields when dealing with HIDDEN sort fields #4234

Closed
opened 2026-01-22 14:37:51 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 5, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @ocramius:

As per discussion in DDC-3336, the Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker does not retain the correct fields in the ORDER BY condition when one of the selected fields is marked as HIDDEN.

As an example, take a DQL query like:

SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC

This will result in an SQL query like:

SELECT DISTINCT id*0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_ ORDER BY name_2 DESC) dctrn*result

Removing the HIDDEN modifier will cause the query to produce the correct SQL:

SELECT DISTINCT id*0, name_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_ ORDER BY name_2 DESC) dctrn_result ORDER BY name*2 DESC

Originally created by @doctrinebot on GitHub (Dec 5, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @ocramius: As per discussion in [DDC-3336](http://www.doctrine-project.org/jira/browse/DDC-3336), the `Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker` does not retain the correct fields in the `ORDER BY` condition when one of the selected fields is marked as `HIDDEN`. As an example, take a DQL query like: `SELECT a, a.name AS HIDDEN ord FROM Doctrine\Tests\ORM\Tools\Pagination\Author a ORDER BY ord DESC` This will result in an SQL query like: `SELECT DISTINCT id*0 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_ ORDER BY name_2 DESC) dctrn*result` Removing the `HIDDEN` modifier will cause the query to produce the correct SQL: `SELECT DISTINCT id*0, name_2 FROM (SELECT a0_.id AS id_0, a0_.name AS name_1, a0_.name AS name_2 FROM Author a0_ ORDER BY name_2 DESC) dctrn_result ORDER BY name*2 DESC`
admin added the Bug label 2026-01-22 14:37:51 +01:00
admin closed this issue 2026-01-22 14:37:52 +01:00
Author
Owner
@doctrinebot commented on GitHub (Dec 5, 2014): - depends on [DDC-3435: [GH-1211] DDC-3434 - paginator ignores `HIDDEN` fields in `ORDER BY` query](http://www.doctrine-project.org/jira/browse/DDC-3435) - relates to [DDC-3336: Undefined property: Doctrine\ORM\Query\AST\SimpleArithmeticExpression::$field](http://www.doctrine-project.org/jira/browse/DDC-3336) - relates to [DDC-1958: pager produces wrong results on postgresql](http://www.doctrine-project.org/jira/browse/DDC-1958)
Author
Owner

@doctrinebot commented on GitHub (Dec 5, 2014):

Comment created by @doctrinebot:

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

@doctrinebot commented on GitHub (Dec 5, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-1210] was closed: https://github.com/doctrine/doctrine2/pull/1210
Author
Owner

@doctrinebot commented on GitHub (Dec 5, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 5, 2014): 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#4234