Skip to content

Commit

Permalink
fix: fix compatibility problem with ORM 2.20 (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi authored Jan 15, 2025
1 parent 550a4cf commit 6c04442
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# 0.22.1

* fix: fix compatibility problem with ORM 2.20

# 0.22.0

* fix: COUNT query must not have LIMIT outside subselect; ORM 2.20 & 3.3 compatibility# 0.21.2
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"type": "library",
"require": {
"php": "^8.2",
"composer-runtime-api": "^2.0",
"api-platform/core": "^3.2 || ^4.0",
"doctrine/collections": "^2.2",
"doctrine/dbal": "^3.8 || ^4.0",
Expand All @@ -31,7 +32,6 @@
"twig/twig": "^3.8"
},
"require-dev": {
"composer-runtime-api": "^2.2",
"bnf/phpstan-psr-container": "^1.0",
"composer/semver": "^3.4",
"doctrine/doctrine-bundle": "^2.11.3",
Expand Down
1 change: 1 addition & 0 deletions packages/rekapager-doctrine-orm-adapter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}
},
"require": {
"composer-runtime-api": "^2.0",
"php": "^8.2",
"doctrine/dbal": "^3.8 || ^4.0",
"doctrine/orm": "^2.19 || ^3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@

namespace Rekalogika\Rekapager\Doctrine\ORM\Internal;

use Composer\InstalledVersions;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Internal\SQLResultCasing;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\SqlOutputWalker;
use Doctrine\ORM\Tools\Pagination\CountWalker;
use Rekalogika\Contracts\Rekapager\Exception\RuntimeException;

/**
* @see Paginator
Expand Down Expand Up @@ -79,7 +80,13 @@ private function getCountQuery(): Query
$rsm = new ResultSetMapping();
$rsm->addScalarResult($this->getSQLResultCasing($platform, 'dctrn_count'), 'count');

if (class_exists(SqlOutputWalker::class)) {
$version = InstalledVersions::getVersion('doctrine/orm');

if ($version === null) {
throw new RuntimeException('Could not determine the installed version of doctrine/orm');
}

if (version_compare($version, '3.0.0', '>=')) {
$outputWalker = CountOutputWalker::class;
} else {
$outputWalker = CountOutputWalker2::class;
Expand Down
2 changes: 2 additions & 0 deletions tests/src/ArchitectureTests/ArchitectureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Rekalogika\Rekapager\Tests\ArchitectureTests;

use Base64Url\Base64Url;
use Composer\InstalledVersions;
use PHPat\Selector\Selector;
use PHPat\Test\Builder\Rule;
use PHPat\Test\PHPat;
Expand Down Expand Up @@ -186,6 +187,7 @@ public function testPackageDoctrineORMAdapter(): Rule
Selector::classname(\Throwable::class),
Selector::classname(\Traversable::class),
Selector::classname(\Countable::class),
Selector::classname(InstalledVersions::class),
);
}

Expand Down

0 comments on commit 6c04442

Please sign in to comment.