From 595489b4c456a6926365e270cdaba8c401350506 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Thu, 5 Dec 2019 08:44:08 +0100 Subject: [PATCH] use executeUpdate for migration queries as it is a write operation --- lib/Doctrine/Migrations/Version/Executor.php | 4 ++-- .../Migrations/Tests/Version/ExecutorTest.php | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Migrations/Version/Executor.php b/lib/Doctrine/Migrations/Version/Executor.php index 76d2798e12..199d91bce4 100644 --- a/lib/Doctrine/Migrations/Version/Executor.php +++ b/lib/Doctrine/Migrations/Version/Executor.php @@ -344,9 +344,9 @@ private function executeVersionExecutionResult( $this->outputSqlQuery($key, $query); if (! isset($this->params[$key])) { - $this->connection->executeQuery($query); + $this->connection->executeUpdate($query); } else { - $this->connection->executeQuery($query, $this->params[$key], $this->types[$key]); + $this->connection->executeUpdate($query, $this->params[$key], $this->types[$key]); } $stopwatchEvent->stop(); diff --git a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php index de4fd93969..c138f5cdbe 100644 --- a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php @@ -107,6 +107,26 @@ public function testExecuteUp() : void self::assertFalse($this->migration->postDownExecuted); } + public function testExecuteUsedExecuteUpdate() : void + { + $this->connection + ->expects(self::never()) + ->method('executeQuery'); + $this->connection + ->expects(self::exactly(2)) + ->method('executeUpdate'); + + $migratorConfiguration = (new MigratorConfiguration()) + ->setTimeAllQueries(true); + + $this->versionExecutor->execute( + $this->version, + $this->migration, + Direction::UP, + $migratorConfiguration + ); + } + /** * @test */