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

Merge pull request #1487 from xxccdef/DDC-3864

[DDC-3864] Support any ordering of fields in partial object query with embeddable
This commit is contained in:
Guilherme Blanco 2015-11-15 22:03:25 -05:00
commit 9f93999758
2 changed files with 26 additions and 1 deletions

View File

@ -1815,7 +1815,16 @@ class Parser
$this->match(Lexer::T_OPEN_CURLY_BRACE); $this->match(Lexer::T_OPEN_CURLY_BRACE);
$this->match(Lexer::T_IDENTIFIER); $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)) { while ($this->lexer->isNextToken(Lexer::T_COMMA)) {
$this->match(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->zip);
$this->assertNull($person->address->country); $this->assertNull($person->address->country);
$this->assertNull($person->name); $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() public function testDqlWithNonExistentEmbeddableField()