Skip to content

Commit

Permalink
#1320 Fix "explain" with pdo_sqlsrv + DBAL 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Apr 5, 2021
1 parent 4d347fa commit 34757c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 13 additions & 0 deletions Controller/ProfilerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
namespace Doctrine\Bundle\DoctrineBundle\Controller;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ForwardCompatibility\Result;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use LogicException;
use PDO;
use PDOStatement;
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -122,6 +125,16 @@ private function explainSQLServerPlatform(Connection $connection, array $query):
}

$stmt = $connection->executeQuery($sql, $params, $query['types']);

// DBAL 2.13 "forward compatibility" BC break handling
if ($stmt instanceof Result) {
$stmt = $stmt->getIterator();
}

if (! $stmt instanceof PDOStatement) {
throw new LogicException('We need nextRowSet() functionality feature, which is not available with current DBAL driver');
}

$stmt->nextRowset();

return $stmt->fetchAll(PDO::FETCH_ASSOC);
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
"autoload-dev": {
"psr-4": { "": "Tests/DependencyInjection" }
},
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev"
}
"suggest": {
"ext-pdo": "*"
}
}

0 comments on commit 34757c3

Please sign in to comment.