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;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_identVariableOrder = 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) {
|
||||
$n = count($this->_identVariableOrder);
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
if (isset($this->_identVariableExpressions[$this->_identVariableOrder[$i]])) {
|
||||
$expr = $this->_identVariableExpressions[$this->_identVariableOrder[$i]];
|
||||
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;
|
||||
@ -1442,7 +1439,6 @@ class Parser
|
||||
|
||||
$token = $this->_lexer->lookahead;
|
||||
$aliasIdentificationVariable = $this->AliasIdentificationVariable();
|
||||
$this->_identVariableOrder[] = $aliasIdentificationVariable;
|
||||
$classMetadata = $this->_em->getClassMetadata($abstractSchemaName);
|
||||
|
||||
// Building queryComponent
|
||||
@ -1533,7 +1529,6 @@ class Parser
|
||||
|
||||
$token = $this->_lexer->lookahead;
|
||||
$aliasIdentificationVariable = $this->AliasIdentificationVariable();
|
||||
$this->_identVariableOrder[] = $aliasIdentificationVariable;
|
||||
|
||||
// Verify that the association exists.
|
||||
$parentClass = $this->_queryComponents[$joinPathExpression->identificationVariable]['metadata'];
|
||||
|
@ -32,11 +32,15 @@ class DDC736Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->flush();
|
||||
$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*/);
|
||||
|
||||
$this->assertTrue($cart2 instanceof ECommerceCart);
|
||||
$this->assertFalse($cart2->getCustomer() instanceof \Doctrine\ORM\Proxy\Proxy);
|
||||
$this->assertTrue($cart2->getCustomer() instanceof ECommerceCustomer);
|
||||
$cart2 = $result[0];
|
||||
unset($result[0]);
|
||||
|
||||
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cart2);
|
||||
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer());
|
||||
$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