From 3e8796f78188e193aac7386b38b7e17da3df5718 Mon Sep 17 00:00:00 2001 From: denkiryokuhatsuden Date: Tue, 2 Apr 2013 18:54:55 +0900 Subject: [PATCH] Add hidden field ordering for postgresql In postgresql environment, when some hidden fields are used in orderBy clause, they're not property added because $rsm->scalarMappings don't have information about them. --- .../Pagination/LimitSubqueryOutputWalker.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 3943cb5e6..a0a22b03b 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -91,7 +91,25 @@ class LimitSubqueryOutputWalker extends SqlWalker */ public function walkSelectStatement(SelectStatement $AST) { - $innerSql = parent::walkSelectStatement($AST); + if ($this->platform instanceof PostgreSqlPlatform) { + // Set every select expression as visible(hidden = false) to + // make $AST to have scalar mappings properly + $hiddens = array(); + foreach ($AST->selectClause->selectExpressions as $idx => $expr) { + $hiddens[$idx] = $expr->hiddenAliasResultVariable; + $expr->hiddenAliasResultVariable = false; + } + + $innerSql = parent::walkSelectStatement($AST); + + // Restore hiddens + foreach ($AST->selectClause->selectExpressions as $idx => $expr) { + $expr->hiddenAliasResultVariable = $hiddens[$idx]; + } + } else { + $innerSql = parent::walkSelectStatement($AST); + } + // Find out the SQL alias of the identifier column of the root entity. // It may be possible to make this work with multiple root entities but that