Skip to content

Commit

Permalink
Rename Doctrine\ORM\Tools\Pagination\WhereInWalker::HINT_PAGINATOR_HA…
Browse files Browse the repository at this point in the history
…S_IDS to HINT_PAGINATOR_HAS_IDS
  • Loading branch information
mpdude committed Feb 17, 2022
1 parent 71a3a10 commit cc84117
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getIterator()
$ids = array_map('current', $foundIdRows);

$this->appendTreeWalker($whereInQuery, WhereInWalker::class);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, $ids !== []);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, $ids !== []);
$whereInQuery->setFirstResult(null)->setMaxResults(null);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, $ids);
$whereInQuery->setCacheable($this->query->isCacheable());
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WhereInWalker extends TreeWalkerAdapter
/**
* ID Count hint name.
*/
public const HINT_PAGINATOR_ID_COUNT = 'doctrine.id.count';
public const HINT_PAGINATOR_HAS_IDS = 'doctrine.paginator_has_ids';

/**
* Primary key alias for query.
Expand All @@ -48,8 +48,8 @@ class WhereInWalker extends TreeWalkerAdapter
* The parameter namespace (dpid) is defined by
* the PAGINATOR_ID_ALIAS
*
* The total number of parameters is retrieved from
* the HINT_PAGINATOR_ID_COUNT query hint.
* The HINT_PAGINATOR_HAS_IDS query hint indicates whether there are
* any ids in the parameter at all.
*
* @return void
*
Expand Down Expand Up @@ -79,7 +79,7 @@ public function walkSelectStatement(SelectStatement $AST)
$pathExpression = new PathExpression(PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $rootAlias, $identifierFieldName);
$pathExpression->type = $pathType;

$hasIds = $this->_getQuery()->getHint(self::HINT_PAGINATOR_ID_COUNT);
$hasIds = $this->_getQuery()->getHint(self::HINT_PAGINATOR_HAS_IDS);

if ($hasIds) {
$arithmeticExpression = new ArithmeticExpression();
Expand Down
24 changes: 12 additions & 12 deletions tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testWhereInQueryNoWhere(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -53,7 +53,7 @@ public function testCountQueryMixedResultsWithName(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -74,7 +74,7 @@ public function testWhereInQuerySingleWhere(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -95,7 +95,7 @@ public function testWhereInQueryMultipleWhereWithAnd(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -116,7 +116,7 @@ public function testWhereInQueryMultipleWhereWithOr(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -137,7 +137,7 @@ public function testWhereInQueryMultipleWhereWithMixed1(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -158,7 +158,7 @@ public function testWhereInQueryMultipleWhereWithMixed2(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -179,7 +179,7 @@ public function testWhereInQueryWhereNot(): void
);
$whereInQuery = clone $query;
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -202,7 +202,7 @@ public function testWhereInQueryWithArbitraryJoinNoWhere(): void
'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c'
);
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -222,7 +222,7 @@ public function testWhereInQueryWithArbitraryJoinSingleWhere(): void
'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p JOIN Doctrine\Tests\ORM\Tools\Pagination\Category c WITH p.category = c WHERE 1 = 1'
);
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 10);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

self::assertEquals(
Expand All @@ -242,7 +242,7 @@ public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerIdent
'SELECT e.id4 FROM ' . AuxiliaryEntity::class . ' e'
);
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 3);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, ['foo', 'bar', 'baz']);

$this->assertPaginatorWhereInParameterToBe(
Expand All @@ -257,7 +257,7 @@ public function testWillReplaceBoundQueryIdentifiersWithConvertedTypesAsPerAssoc
'SELECT e FROM ' . OwningManyToOneIdForeignKeyEntity::class . ' e'
);
$whereInQuery->setHint(Query::HINT_CUSTOM_TREE_WALKERS, [WhereInWalker::class]);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, 3);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_HAS_IDS, true);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, ['foo', 'bar', 'baz']);

$this->assertPaginatorWhereInParameterToBe(
Expand Down

0 comments on commit cc84117

Please sign in to comment.