1
0
mirror of synced 2025-01-29 19:41:45 +03:00

DDC-736 - Simplified patch and extended test to verify scalar results are still in order.

This commit is contained in:
Benjamin Eberlei 2010-11-13 09:52:35 +01:00
parent e4280cf82e
commit d3d3032759
2 changed files with 15 additions and 16 deletions

View File

@ -125,11 +125,6 @@ class Parser
*/ */
private $_customOutputWalker; private $_customOutputWalker;
/**
* @var array
*/
private $_identVariableOrder = array();
/** /**
* @var array * @var array
*/ */
@ -307,12 +302,14 @@ class Parser
} }
} }
// fix order of identification variables // 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) { if ( count($this->_identVariableExpressions) > 1) {
$n = count($this->_identVariableOrder); foreach ($this->_queryComponents as $dqlAlias => $qComp) {
for ($i = 0; $i < $n; $i++) { if (isset($this->_identVariableExpressions[$dqlAlias])) {
if (isset($this->_identVariableExpressions[$this->_identVariableOrder[$i]])) { $expr = $this->_identVariableExpressions[$dqlAlias];
$expr = $this->_identVariableExpressions[$this->_identVariableOrder[$i]];
$key = array_search($expr, $AST->selectClause->selectExpressions); $key = array_search($expr, $AST->selectClause->selectExpressions);
unset($AST->selectClause->selectExpressions[$key]); unset($AST->selectClause->selectExpressions[$key]);
$AST->selectClause->selectExpressions[] = $expr; $AST->selectClause->selectExpressions[] = $expr;
@ -1442,7 +1439,6 @@ class Parser
$token = $this->_lexer->lookahead; $token = $this->_lexer->lookahead;
$aliasIdentificationVariable = $this->AliasIdentificationVariable(); $aliasIdentificationVariable = $this->AliasIdentificationVariable();
$this->_identVariableOrder[] = $aliasIdentificationVariable;
$classMetadata = $this->_em->getClassMetadata($abstractSchemaName); $classMetadata = $this->_em->getClassMetadata($abstractSchemaName);
// Building queryComponent // Building queryComponent
@ -1533,7 +1529,6 @@ class Parser
$token = $this->_lexer->lookahead; $token = $this->_lexer->lookahead;
$aliasIdentificationVariable = $this->AliasIdentificationVariable(); $aliasIdentificationVariable = $this->AliasIdentificationVariable();
$this->_identVariableOrder[] = $aliasIdentificationVariable;
// Verify that the association exists. // Verify that the association exists.
$parentClass = $this->_queryComponents[$joinPathExpression->identificationVariable]['metadata']; $parentClass = $this->_queryComponents[$joinPathExpression->identificationVariable]['metadata'];

View File

@ -32,11 +32,15 @@ class DDC736Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$cart2 = $this->_em->createQuery("select c, ca from Doctrine\Tests\Models\ECommerce\ECommerceCart ca join ca.customer c") $result = $this->_em->createQuery("select c, c.name, ca, ca.payment from Doctrine\Tests\Models\ECommerce\ECommerceCart ca join ca.customer c")
->getSingleResult(/*\Doctrine\ORM\Query::HYDRATE_ARRAY*/); ->getSingleResult(/*\Doctrine\ORM\Query::HYDRATE_ARRAY*/);
$cart2 = $result[0];
unset($result[0]);
$this->assertTrue($cart2 instanceof ECommerceCart); $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cart2);
$this->assertFalse($cart2->getCustomer() instanceof \Doctrine\ORM\Proxy\Proxy); $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer());
$this->assertTrue($cart2->getCustomer() instanceof ECommerceCustomer); $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart2->getCustomer());
$this->assertEquals(array('name' => 'roman', 'payment' => 'cash'), $result);
} }
} }