From 8557a3227a5ecdfee613671040048e3a91e9b140 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 22 Sep 2020 15:06:04 -0700 Subject: [PATCH] Restore PDOStatement::quote() for backward compatibility --- lib/Doctrine/DBAL/Driver/PDOConnection.php | 9 +++++++++ phpcs.xml.dist | 5 +++++ .../DBAL/Functional/Driver/PDO/ConnectionTest.php | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index 43b8280ef70..8409952cb4e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\Connection as ConnectionInterface; use Doctrine\DBAL\Driver\PDO\Exception; use Doctrine\DBAL\Driver\PDO\Statement; +use Doctrine\DBAL\ParameterType; use PDO; use PDOException; use PDOStatement; @@ -101,6 +102,14 @@ public function query() } } + /** + * {@inheritdoc} + */ + public function quote($value, $type = ParameterType::STRING) + { + return parent::quote($value, $type); + } + /** * {@inheritdoc} */ diff --git a/phpcs.xml.dist b/phpcs.xml.dist index c82ca439eca..8c6b82da6b0 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -110,6 +110,11 @@ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php + + + lib/Doctrine/DBAL/Driver/PDOConnection.php + + lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php index f54cb07b06a..c9f748fbce6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php @@ -1,5 +1,7 @@ driverConnection->query('foo'); } + + /** + * This test ensures backward compatibility with DBAL 2.x and should be removed in 3.0. + */ + public function testQuoteInteger(): void + { + self::assertSame("'1'", $this->connection->getWrappedConnection()->quote(1)); + } }