1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Merge branch 'hotfix/#1295-fix-join-when-re-creating-query-builder-from-parts'

Close #1295
This commit is contained in:
Marco Pivetta 2015-02-16 01:23:54 +00:00
commit b5238966d1
2 changed files with 29 additions and 1 deletions

View File

@ -690,7 +690,13 @@ class QueryBuilder
);
}
$isMultiple = is_array($this->_dqlParts[$dqlPartName]);
$isMultiple = is_array($this->_dqlParts[$dqlPartName])
&& !($dqlPartName == 'join' && !$append);
// Allow adding any part retrieved from self::getDQLParts().
if (is_array($dqlPart) && $dqlPartName != 'join') {
$dqlPart = reset($dqlPart);
}
// This is introduced for backwards compatibility reasons.
// TODO: Remove for 3.0

View File

@ -1098,4 +1098,26 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals('foo_reg', $query->getCacheRegion());
$this->assertEquals(Cache::MODE_REFRESH, $query->getCacheMode());
}
/**
* @group DDC-2253
*/
public function testRebuildsFromParts()
{
$qb = $this->_em->createQueryBuilder()
->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->join('u.article', 'a');
$dqlParts = $qb->getDQLParts();
$dql = $qb->getDQL();
$qb2 = $this->_em->createQueryBuilder();
foreach (array_filter($dqlParts) as $name => $part) {
$qb2->add($name, $part);
}
$dql2 = $qb2->getDQL();
$this->assertEquals($dql, $dql2);
}
}