Skip to content

Commit

Permalink
use executeUpdate for migration queries as it is a write operation
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Dec 1, 2019
1 parent f92df45 commit ac84073
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/Migrations/Version/DbalExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 21 additions & 0 deletions tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ac84073

Please sign in to comment.