[DDC-2764] Prefix criteria orderBy with rootAlias
This commit is contained in:
parent
45496f040d
commit
2c114756bd
@ -1098,7 +1098,7 @@ class QueryBuilder
|
|||||||
|
|
||||||
if ($criteria->getOrderings()) {
|
if ($criteria->getOrderings()) {
|
||||||
foreach ($criteria->getOrderings() as $sort => $order) {
|
foreach ($criteria->getOrderings() as $sort => $order) {
|
||||||
$this->addOrderBy($sort, $order);
|
$this->addOrderBy($this->getRootAlias() . '.' . $sort, $order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,13 +414,16 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
public function testAddCriteriaOrder()
|
public function testAddCriteriaOrder()
|
||||||
{
|
{
|
||||||
$qb = $this->_em->createQueryBuilder();
|
$qb = $this->_em->createQueryBuilder();
|
||||||
|
$qb->select('u')
|
||||||
|
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u');
|
||||||
|
|
||||||
$criteria = new Criteria();
|
$criteria = new Criteria();
|
||||||
$criteria->orderBy(array('field' => Criteria::DESC));
|
$criteria->orderBy(array('field' => Criteria::DESC));
|
||||||
|
|
||||||
$qb->addCriteria($criteria);
|
$qb->addCriteria($criteria);
|
||||||
|
|
||||||
$this->assertCount(1, $orderBy = $qb->getDQLPart('orderBy'));
|
$this->assertCount(1, $orderBy = $qb->getDQLPart('orderBy'));
|
||||||
$this->assertEquals('field DESC', (string) $orderBy[0]);
|
$this->assertEquals('u.field DESC', (string) $orderBy[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddCriteriaLimit()
|
public function testAddCriteriaLimit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user