DDC-736 - Simplified patch and extended test to verify scalar results are still in order.
This commit is contained in:
parent
e4280cf82e
commit
d3d3032759
@ -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'];
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user