From 34757c3df0e8c7750d68d01ea78798febd0eae8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Mon, 5 Apr 2021 15:19:55 +0200 Subject: [PATCH] #1320 Fix "explain" with pdo_sqlsrv + DBAL 2.13 --- Controller/ProfilerController.php | 13 +++++++++++++ composer.json | 6 ++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Controller/ProfilerController.php b/Controller/ProfilerController.php index 229db9fdb..302590ca9 100644 --- a/Controller/ProfilerController.php +++ b/Controller/ProfilerController.php @@ -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; @@ -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); diff --git a/composer.json b/composer.json index feb629344..73a4fee51 100644 --- a/composer.json +++ b/composer.json @@ -71,9 +71,7 @@ "autoload-dev": { "psr-4": { "": "Tests/DependencyInjection" } }, - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } + "suggest": { + "ext-pdo": "*" } }