Skip to content

Commit 967d5c3

Browse files
committed
fix: error in DBAL 2.x (#5)
1 parent 42952a9 commit 967d5c3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Adapter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Doctrine\DBAL\Connection;
1818
use Doctrine\DBAL\Exception;
1919
use Doctrine\DBAL\Query\Expression\CompositeExpression;
20-
use Doctrine\DBAL\Result;
2120
use Doctrine\DBAL\Schema\Schema;
2221
use Throwable;
2322

@@ -487,12 +486,12 @@ public function getColumns(): array
487486
}
488487

489488
/**
490-
* @param mixed $stmt
489+
* @param \Doctrine\DBAL\Result|\Doctrine\DBAL\Driver\PDOStatement $stmt
491490
*
492491
* @return mixed
493492
* @throws Exception
494493
*/
495-
private function fetch(Result $stmt)
494+
private function fetch($stmt)
496495
{
497496
if (method_exists($stmt, 'fetchAssociative')) {
498497
return $stmt->fetchAssociative();

tests/AdapterTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public function testUpdateFilteredPolicies()
4040
["p", "bob", "data", "write", "allow"]
4141
], $oldRules);
4242

43-
$result = $conn->createQueryBuilder()->from($adapter->policyTableName)->where('p_type = "p" and v1 = "data" and v3 = "allow"')->select("v0", "v1", "v2", "v3")->execute()->fetchAllAssociative();
43+
$stmt = $conn->createQueryBuilder()->from($adapter->policyTableName)->where('p_type = "p" and v1 = "data" and v3 = "allow"')->select("v0", "v1", "v2", "v3")->execute();
44+
$result = method_exists($stmt, 'fetchAssociative') ? $stmt->fetchAllAssociative() : $stmt->fetchAll();
45+
4446
$result = array_map([$adapter, "filterRule"], $result);
4547

4648
$this->assertEquals($newPolicies, $result);

0 commit comments

Comments
 (0)