From ac84073ceaae06bc405c3b2ef44bdc5b084d4294 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sun, 1 Dec 2019 09:52:51 +0100 Subject: [PATCH] use executeUpdate for migration queries as it is a write operation --- .../Migrations/Version/DbalExecutor.php | 4 ++-- .../Migrations/Tests/Version/ExecutorTest.php | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Migrations/Version/DbalExecutor.php b/lib/Doctrine/Migrations/Version/DbalExecutor.php index 17f23d7075..d3ee27444b 100644 --- a/lib/Doctrine/Migrations/Version/DbalExecutor.php +++ b/lib/Doctrine/Migrations/Version/DbalExecutor.php @@ -333,9 +333,9 @@ private function executeResult(MigratorConfiguration $configuration) : void $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 6ffa9c037d..17b7a9ff0a 100644 --- a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php @@ -111,6 +111,27 @@ public function testExecuteUp() : void ], $this->logger->logs); } + public function testExecuteUsedExecuteUpdate() : void + { + $this->connection + ->expects(self::never()) + ->method('executeQuery'); + + $this->connection + ->expects(self::exactly(2)) + ->method('executeUpdate'); + + $migratorConfiguration = (new MigratorConfiguration()) + ->setTimeAllQueries(true); + + $plan = new MigrationPlan($this->version, $this->migration, Direction::UP); + + $this->versionExecutor->execute( + $plan, + $migratorConfiguration + ); + } + /** * @test */