From 5e788a0b8467cfccca0dc622396516ddce3df10e Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 8 Dec 2010 23:42:02 +0100 Subject: [PATCH] DDC-915 - Bugfix in Identification Variable reordering in combination with SQL Walkers. --- lib/Doctrine/ORM/Query/Parser.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index e5b9f69ca..26dfb0535 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -277,6 +277,21 @@ class Parser { $AST = $this->getAST(); + // Fix order of identification variables. + // They have to appear in the select clause in the same order as the + // declarations (from ... x join ... y join ... z ...) appear in the query + // as the hydration process relies on that order for proper operation. + if ( count($this->_identVariableExpressions) > 1) { + foreach ($this->_queryComponents as $dqlAlias => $qComp) { + if (isset($this->_identVariableExpressions[$dqlAlias])) { + $expr = $this->_identVariableExpressions[$dqlAlias]; + $key = array_search($expr, $AST->selectClause->selectExpressions); + unset($AST->selectClause->selectExpressions[$key]); + $AST->selectClause->selectExpressions[] = $expr; + } + } + } + if (($customWalkers = $this->_query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) { $this->_customTreeWalkers = $customWalkers; } @@ -302,21 +317,6 @@ class Parser } } - // Fix order of identification variables. - // They have to appear in the select clause in the same order as the - // declarations (from ... x join ... y join ... z ...) appear in the query - // as the hydration process relies on that order for proper operation. - if ( count($this->_identVariableExpressions) > 1) { - foreach ($this->_queryComponents as $dqlAlias => $qComp) { - if (isset($this->_identVariableExpressions[$dqlAlias])) { - $expr = $this->_identVariableExpressions[$dqlAlias]; - $key = array_search($expr, $AST->selectClause->selectExpressions); - unset($AST->selectClause->selectExpressions[$key]); - $AST->selectClause->selectExpressions[] = $expr; - } - } - } - if ($this->_customOutputWalker) { $outputWalker = new $this->_customOutputWalker( $this->_query, $this->_parserResult, $this->_queryComponents