c7a75f477f
This fixes DDC-1958
49 lines
1.9 KiB
PHP
49 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Doctrine\Tests\ORM\Tools\Pagination;
|
|
|
|
use Doctrine\ORM\Query;
|
|
|
|
/**
|
|
* @group DDC-1613
|
|
*/
|
|
class LimitSubqueryWalkerTest extends PaginationTestCase
|
|
{
|
|
public function testLimitSubquery()
|
|
{
|
|
$query = $this->entityManager->createQuery(
|
|
'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a');
|
|
$limitQuery = clone $query;
|
|
$limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker'));
|
|
|
|
$this->assertEquals(
|
|
"SELECT DISTINCT m0_.id AS id0 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id", $limitQuery->getSql()
|
|
);
|
|
}
|
|
|
|
public function testLimitSubqueryWithSort()
|
|
{
|
|
$query = $this->entityManager->createQuery(
|
|
'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\MyBlogPost p JOIN p.category c JOIN p.author a ORDER BY p.title');
|
|
$limitQuery = clone $query;
|
|
$limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker'));
|
|
|
|
$this->assertEquals(
|
|
"SELECT DISTINCT m0_.id AS id0, m0_.title AS title1 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id ORDER BY m0_.title ASC", $limitQuery->getSql()
|
|
);
|
|
}
|
|
|
|
public function testCountQuery_MixedResultsWithName()
|
|
{
|
|
$query = $this->entityManager->createQuery(
|
|
'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a');
|
|
$limitQuery = clone $query;
|
|
$limitQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker'));
|
|
|
|
$this->assertEquals(
|
|
"SELECT DISTINCT a0_.id AS id0, sum(a0_.name) AS sclr1 FROM Author a0_", $limitQuery->getSql()
|
|
);
|
|
}
|
|
}
|
|
|