1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Set rootAlias outside loop

This commit is contained in:
Sander Marechal 2013-11-01 13:19:33 +01:00
parent b6f8d53ff1
commit 202039e853
2 changed files with 13 additions and 2 deletions

View File

@ -1096,9 +1096,10 @@ class QueryBuilder
}
}
$rootAlias = $this->getRootAlias();
if ($criteria->getOrderings()) {
foreach ($criteria->getOrderings() as $sort => $order) {
$this->addOrderBy($this->getRootAlias() . '.' . $sort, $order);
$this->addOrderBy($rootAlias . '.' . $sort, $order);
}
}

View File

@ -402,6 +402,9 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testAddCriteriaWhere()
{
$qb = $this->_em->createQueryBuilder();
$qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('field', 'value'));
@ -429,6 +432,9 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testAddCriteriaLimit()
{
$qb = $this->_em->createQueryBuilder();
$qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$criteria = new Criteria();
$criteria->setFirstResult(2);
$criteria->setMaxResults(10);
@ -442,7 +448,11 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
public function testAddCriteriaUndefinedLimit()
{
$qb = $this->_em->createQueryBuilder();
$qb->setFirstResult(2)->setMaxResults(10);
$qb->select('u')
->from('Doctrine\Tests\Models\CMS\CmsUser', 'u')
->setFirstResult(2)
->setMaxResults(10);
$criteria = new Criteria();
$qb->addCriteria($criteria);