diff --git a/src/Statement.php b/src/Statement.php index f6cb047..b5ea4cc 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -117,8 +117,6 @@ private function executeWithRetry(callable $callable, ...$params) goto attempt; } - $this->retriableConnection->resetAttemptCount(); - /** @psalm-suppress PossiblyUndefinedVariable */ return $result; } diff --git a/tests/Functional/ConnectionTraitTest.php b/tests/Functional/ConnectionTraitTest.php index 3ba6dcd..72bc6d0 100644 --- a/tests/Functional/ConnectionTraitTest.php +++ b/tests/Functional/ConnectionTraitTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\PDO\MySQL\Driver as PDODriver; use Doctrine\DBAL\Exception; +use Doctrine\DBAL\ParameterType; class ConnectionTraitTest extends AbstractFunctionalTestCase { @@ -135,6 +136,35 @@ public function testShouldResetStatementOnStatementExecuteError(string $driver, $this->assertConnectionCount(2, $connection); } + /** + * @dataProvider driverDataProvider + * + * @param class-string $driver + */ + public function testBindParamShouldRespectTypeWhenRecreatingStatement(string $driver, bool $enableSavepoints): void + { + $connection = $this->getConnectedConnection($driver, 1, $enableSavepoints); + $this->assertConnectionCount(1, $connection); + + $statement = $connection->prepare("SELECT 'foo', ?, ?"); + $statement->bindValue(1, 'bar'); + $param = 1; + /** @psalm-suppress DeprecatedMethod */ + $statement->bindParam(2, $param, ParameterType::INTEGER); + // change param by ref + $param = 2; + if (PDODriver::class === $driver) { + // PDO driver returns result always as string + $param = (string) $param; + } + + $this->forceDisconnect($connection); + $result = $statement->executeQuery()->fetchAllNumeric(); + + $this->assertSame([['foo', 'bar', $param]], $result); + $this->assertConnectionCount(2, $connection); + } + /** * @dataProvider driverDataProvider *