[DDC-2764] Prefix criteria orderBy with rootAlias
This commit is contained in:
parent
514dd4e852
commit
b6f8d53ff1
@ -1098,7 +1098,7 @@ class QueryBuilder
|
||||
|
||||
if ($criteria->getOrderings()) {
|
||||
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()
|
||||
{
|
||||
$qb = $this->_em->createQueryBuilder();
|
||||
$qb->select('u')
|
||||
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u');
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->orderBy(array('field' => Criteria::DESC));
|
||||
|
||||
$qb->addCriteria($criteria);
|
||||
|
||||
$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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user