1
0
mirror of synced 2025-02-03 05:49:25 +03:00

Support any ordering of fields in partial object query with embeddable [DDC-3864]

This commit is contained in:
Egidijus Jucevičius 2015-08-04 10:56:50 +03:00
parent 71b1dde096
commit d4d9a2ba3c
2 changed files with 26 additions and 1 deletions

View File

@ -1779,7 +1779,16 @@ class Parser
$this->match(Lexer::T_OPEN_CURLY_BRACE);
$this->match(Lexer::T_IDENTIFIER);
$partialFieldSet[] = $this->lexer->token['value'];
$field = $this->lexer->token['value'];
// First field in partial expression might be embeddable property
while ($this->lexer->isNextToken(Lexer::T_DOT)) {
$this->match(Lexer::T_DOT);
$this->match(Lexer::T_IDENTIFIER);
$field .= '.'.$this->lexer->token['value'];
}
$partialFieldSet[] = $field;
while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
$this->match(Lexer::T_COMMA);

View File

@ -207,6 +207,22 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertNull($person->address->zip);
$this->assertNull($person->address->country);
$this->assertNull($person->name);
// Clear the EM and prove that the embeddable can be the subject of a partial query regardless of attributes positions.
$this->_em->clear();
$dql = "SELECT PARTIAL p.{address.city, id} FROM " . __NAMESPACE__ ."\\DDC93Person p WHERE p.name = :name";
$person = $this->_em->createQuery($dql)
->setParameter('name', 'Karl')
->getSingleResult();
// Selected field must be equal, all other fields must be null.
$this->assertEquals('Gosport', $person->address->city);
$this->assertNull($person->address->street);
$this->assertNull($person->address->zip);
$this->assertNull($person->address->country);
$this->assertNull($person->name);
}
public function testDqlWithNonExistentEmbeddableField()