Merge branch 'hotfix/#1295-fix-join-when-re-creating-query-builder-from-parts'
Close #1295
This commit is contained in:
commit
b5238966d1
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user