1
0
mirror of synced 2025-01-17 22:11:41 +03:00

[DDC-2764] Prefix criteria orderBy with rootAlias

This commit is contained in:
Sander Marechal 2013-10-29 11:10:34 +01:00
parent 514dd4e852
commit b6f8d53ff1
2 changed files with 5 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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()