diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountSqlWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php similarity index 99% rename from lib/Doctrine/ORM/Tools/Pagination/CountSqlWalker.php rename to lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php index 51e6c2e4b..47df1192f 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountSqlWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php @@ -27,7 +27,7 @@ use Doctrine\ORM\Query\SqlWalker, * * @author Sander Marechal */ -class CountSqlWalker extends SqlWalker +class CountOutputWalker extends SqlWalker { /** * @var Doctrine\DBAL\Platforms\AbstractPlatform diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 3070437d3..2f80f7f63 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -44,7 +44,7 @@ class CountWalker extends TreeWalkerAdapter public function walkSelectStatement(SelectStatement $AST) { if ($AST->havingClause) { - throw new \RuntimeException('Cannot count query that uses a HAVING clause. Use the SQL walkers for pagination'); + throw new \RuntimeException('Cannot count query that uses a HAVING clause. Use the output walkers for pagination'); } $rootComponents = array(); diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubquerySqlWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php similarity index 98% rename from lib/Doctrine/ORM/Tools/Pagination/LimitSubquerySqlWalker.php rename to lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index cbea28c65..e703ea0b8 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubquerySqlWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -27,7 +27,7 @@ use Doctrine\ORM\Query\SqlWalker, * * @author Sander Marechal */ -class LimitSubquerySqlWalker extends SqlWalker +class LimitSubqueryOutputWalker extends SqlWalker { /** * @var Doctrine\DBAL\Platforms\AbstractPlatform diff --git a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php index c854aeba6..566ecdf12 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/Paginator.php +++ b/lib/Doctrine/ORM/Tools/Pagination/Paginator.php @@ -48,7 +48,7 @@ class Paginator implements \Countable, \IteratorAggregate /** * @var bool|null */ - private $useSqlWalkers; + private $useOutputWalkers; /** * @var int @@ -92,24 +92,24 @@ class Paginator implements \Countable, \IteratorAggregate } /** - * Returns whether the paginator will use an SQL TreeWalker + * Returns whether the paginator will use an output walker * * @return bool|null */ - public function getUseSqlWalkers() + public function getUseOutputWalkers() { - return $this->useSqlWalkers; + return $this->useOutputWalkers; } /** - * Set whether the paginator will use an SQL TreeWalker + * Set whether the paginator will use an output walker * - * @param bool|null $useSqlWalkers + * @param bool|null $useOutputWalkers * @return $this */ - public function setUseSqlWalkers($useSqlWalkers) + public function setUseOutputWalkers($useOutputWalkers) { - $this->useSqlWalkers = $useSqlWalkers; + $this->useOutputWalkers = $useOutputWalkers; return $this; } @@ -126,11 +126,11 @@ class Paginator implements \Countable, \IteratorAggregate $countQuery->setHint(CountWalker::HINT_DISTINCT, true); } - if ($this->useSqlWalker($countQuery)) { + if ($this->useOutputWalker($countQuery)) { $rsm = new ResultSetMapping(); $rsm->addScalarResult('_dctrn_count', 'count'); - $countQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountSqlWalker'); + $countQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); $countQuery->setResultSetMapping($rsm); } else { $countQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\CountWalker')); @@ -160,8 +160,8 @@ class Paginator implements \Countable, \IteratorAggregate if ($this->fetchJoinCollection) { $subQuery = $this->cloneQuery($this->query); - if ($this->useSqlWalker($subQuery)) { - $subQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubquerySqlWalker'); + if ($this->useOutputWalker($subQuery)) { + $subQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); } else { $subQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\ORM\Tools\Pagination\LimitSubqueryWalker')); } @@ -215,19 +215,19 @@ class Paginator implements \Countable, \IteratorAggregate } /** - * Determine whether to use an SQL TreeWalker for the query + * Determine whether to use an output walker for the query * * @param Query $query The query. * * @return bool */ - private function useSqlWalker(Query $query) + private function useOutputWalker(Query $query) { - if ($this->useSqlWalkers === null) { + if ($this->useOutputWalkers === null) { return (Boolean) $query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER) == false; } - return $this->useSqlWalkers; + return $this->useOutputWalkers; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index b99e5ee08..c30ecb2a1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -25,104 +25,104 @@ class PaginationTest extends \Doctrine\Tests\OrmFunctionalTestCase } /** - * @dataProvider useSqlWalkers + * @dataProvider useOutputWalkers */ - public function testCountSimpleWithoutJoin($useSqlWalkers) + public function testCountSimpleWithoutJoin($useOutputWalkers) { $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query); - $paginator->setUseSqlWalkers($useSqlWalkers); + $paginator->setUseOutputWalkers($useOutputWalkers); $this->assertCount(3, $paginator); } /** - * @dataProvider useSqlWalkers + * @dataProvider useOutputWalkers */ - public function testCountWithFetchJoin($useSqlWalkers) + public function testCountWithFetchJoin($useOutputWalkers) { $dql = "SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query); - $paginator->setUseSqlWalkers($useSqlWalkers); + $paginator->setUseOutputWalkers($useOutputWalkers); $this->assertCount(3, $paginator); } - public function testCountComplexWithSqlWalker() + public function testCountComplexWithOutputWalker() { $dql = "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query); - $paginator->setUseSqlWalkers(true); + $paginator->setUseOutputWalkers(true); $this->assertCount(9, $paginator); } /** - * @dataProvider useSqlWalkers + * @dataProvider useOutputWalkers */ - public function testIterateSimpleWithoutJoinFetchJoinHandlingOff($useSqlWalkers) + public function testIterateSimpleWithoutJoinFetchJoinHandlingOff($useOutputWalkers) { $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query, false); - $paginator->setUseSqlWalkers($useSqlWalkers); + $paginator->setUseOutputWalkers($useOutputWalkers); $this->assertCount(3, $paginator->getIterator()); } /** - * @dataProvider useSqlWalkers + * @dataProvider useOutputWalkers */ - public function testIterateSimpleWithoutJoinFetchJoinHandlingOn($useSqlWalkers) + public function testIterateSimpleWithoutJoinFetchJoinHandlingOn($useOutputWalkers) { $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query, true); - $paginator->setUseSqlWalkers($useSqlWalkers); + $paginator->setUseOutputWalkers($useOutputWalkers); $this->assertCount(3, $paginator->getIterator()); } /** - * @dataProvider useSqlWalkers + * @dataProvider useOutputWalkers */ - public function testIterateWithFetchJoin($useSqlWalkers) + public function testIterateWithFetchJoin($useOutputWalkers) { $dql = "SELECT u,g FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.groups g"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query, true); - $paginator->setUseSqlWalkers($useSqlWalkers); + $paginator->setUseOutputWalkers($useOutputWalkers); $this->assertCount(3, $paginator->getIterator()); } - public function testIterateComplexWithSqlWalker() + public function testIterateComplexWithOutputWalker() { $dql = "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0"; $query = $this->_em->createQuery($dql); $paginator = new Paginator($query); - $paginator->setUseSqlWalkers(true); + $paginator->setUseOutputWalkers(true); $this->assertCount(9, $paginator->getIterator()); } - public function testDetectSqlWalker() + public function testDetectOutputWalker() { - // This query works using the SQL walkers but causes an exception using the TreeWalker + // This query works using the output walkers but causes an exception using the TreeWalker $dql = "SELECT g, COUNT(u.id) AS userCount FROM Doctrine\Tests\Models\CMS\CmsGroup g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0"; $query = $this->_em->createQuery($dql); - // If the Paginator detects the custom SQL walker it should fall back to using the - // Tree walkers for pagination, which leads to an exception. If the query works, the SQL walkers were used + // If the Paginator detects the custom output walker it should fall back to using the + // Tree walkers for pagination, which leads to an exception. If the query works, the output walkers were used $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Query\SqlWalker'); $paginator = new Paginator($query); $this->setExpectedException( 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the SQL walkers for pagination' + 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' ); count($paginator); @@ -147,7 +147,7 @@ class PaginationTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->flush(); } - public function useSqlWalkers() + public function useOutputWalkers() { return array( array(true), diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountSqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php similarity index 92% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/CountSqlWalkerTest.php rename to tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php index 0b4b1a2c2..9dd0b33e6 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountSqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php @@ -5,13 +5,13 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; use Doctrine\ORM\Query; use Doctrine\ORM\Tools\Pagination\CountWalker; -class CountSqlWalkerTest extends PaginationTestCase +class CountOutputWalkerTest extends PaginationTestCase { public function testCountQuery() { $query = $this->entityManager->createQuery( 'SELECT p, c, a FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN p.category c JOIN p.author a'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountSqlWalker'); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); @@ -24,7 +24,7 @@ class CountSqlWalkerTest extends PaginationTestCase { $query = $this->entityManager->createQuery( 'SELECT a, sum(a.name) as foo FROM Doctrine\Tests\ORM\Tools\Pagination\Author a'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountSqlWalker'); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); $query->setHint(CountWalker::HINT_DISTINCT, true); $query->setFirstResult(null)->setMaxResults(null); @@ -37,7 +37,7 @@ class CountSqlWalkerTest extends PaginationTestCase { $query = $this->entityManager->createQuery( 'SELECT g, u, count(u.id) AS userCount FROM Doctrine\Tests\ORM\Tools\Pagination\Group g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0'); - $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountSqlWalker'); + $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker'); $query->setFirstResult(null)->setMaxResults(null); $this->assertEquals( diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php index 2495ecfaf..405b63a1f 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php @@ -85,7 +85,7 @@ class CountWalkerTest extends PaginationTestCase $this->setExpectedException( 'RuntimeException', - 'Cannot count query that uses a HAVING clause. Use the SQL walkers for pagination' + 'Cannot count query that uses a HAVING clause. Use the output walkers for pagination' ); $query->getSql(); diff --git a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubquerySqlWalkerTest.php b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php similarity index 87% rename from tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubquerySqlWalkerTest.php rename to tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php index 78d2880c5..712fb5f62 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubquerySqlWalkerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php @@ -4,14 +4,14 @@ namespace Doctrine\Tests\ORM\Tools\Pagination; use Doctrine\ORM\Query; -class LimitSubquerySqlWalkerTest extends PaginationTestCase +class LimitSubqueryOutputWalkerTest 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_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubquerySqlWalker'); + $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( "SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, c1_.id AS id1, a2_.id AS id2, a2_.name AS name3, m0_.author_id AS author_id4, m0_.category_id AS category_id5 FROM MyBlogPost m0_ INNER JOIN Category c1_ ON m0_.category_id = c1_.id INNER JOIN Author a2_ ON m0_.author_id = a2_.id) AS _dctrn_result", $limitQuery->getSql() @@ -23,7 +23,7 @@ class LimitSubquerySqlWalkerTest extends PaginationTestCase $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_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubquerySqlWalker'); + $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $this->assertEquals( "SELECT DISTINCT id0 FROM (SELECT a0_.id AS id0, a0_.name AS name1, sum(a0_.name) AS sclr2 FROM Author a0_) AS _dctrn_result", $limitQuery->getSql()