Skip to content

Commit

Permalink
Remove support for DBAL 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Nov 22, 2022
1 parent ea75e4e commit c391085
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 3.7.0 (????-??-??)

- Undeprecate `PagerfantaInterface::getAdapter()`
- Drop support for `doctrine/dbal` 2.x

## 3.6.2 (2022-07-21)

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"require-dev": {
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/collections": "^1.6",
"doctrine/dbal": "^2.13.1 || ^3.1",
"doctrine/dbal": "^3.1",
"doctrine/mongodb-odm": "^2.2.2",
"doctrine/orm": "^2.8",
"doctrine/phpcr-odm": "^1.5",
Expand All @@ -32,7 +32,7 @@
},
"conflict": {
"doctrine/collections": "<1.6",
"doctrine/dbal": "<2.13.1 || ~3.0.0",
"doctrine/dbal": "<3.1",
"doctrine/mongodb-odm": "<2.2.2",
"doctrine/orm": "<2.8",
"doctrine/phpcr-odm": "<1.5",
Expand Down
20 changes: 5 additions & 15 deletions lib/Adapter/Doctrine/DBAL/QueryAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ public function getNbResults(): int
{
$qb = $this->prepareCountQueryBuilder();

if (method_exists($qb, 'executeQuery')) {
return (int) $qb->executeQuery()->fetchOne();
}

return (int) $qb->execute()->fetchOne();
return (int) $qb->executeQuery()->fetchOne();
}

/**
Expand All @@ -61,16 +57,10 @@ public function getSlice(int $offset, int $length): iterable
{
$qb = clone $this->queryBuilder;

$qb->setMaxResults($length)
->setFirstResult($offset);

if (method_exists($qb, 'executeQuery')) {
$stmt = $qb->executeQuery();
} else {
$stmt = $qb->execute();
}

return $stmt->fetchAllAssociative();
return $qb->setMaxResults($length)
->setFirstResult($offset)
->executeQuery()
->fetchAllAssociative();
}

private function prepareCountQueryBuilder(): QueryBuilder
Expand Down
8 changes: 1 addition & 7 deletions lib/Adapter/Doctrine/DBAL/Tests/QueryAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ public function testGetSlice(): void
$this->qb->setFirstResult($offset)
->setMaxResults($length);

if (method_exists($this->qb, 'executeQuery')) {
$stmt = $this->qb->executeQuery();
} else {
$stmt = $this->qb->execute();
}

$this->assertSame($stmt->fetchAllAssociative(), $adapter->getSlice($offset, $length));
$this->assertSame($this->qb->executeQuery()->fetchAllAssociative(), $adapter->getSlice($offset, $length));
}

public function testTheAdapterUsesAClonedQuery(): void
Expand Down
2 changes: 1 addition & 1 deletion lib/Adapter/Doctrine/DBAL/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"doctrine/dbal": "^2.13.1 || ^3.1",
"doctrine/dbal": "^3.1",
"pagerfanta/core": "^3.0"
},
"require-dev": {
Expand Down

0 comments on commit c391085

Please sign in to comment.