1
0
mirror of synced 2024-12-14 07:06:04 +03:00

DDC-915 - Bugfix in Identification Variable reordering in combination with SQL Walkers.

This commit is contained in:
Benjamin Eberlei 2010-12-08 23:42:02 +01:00
parent 1daf658ec6
commit 5e788a0b84

View File

@ -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