Skip to content

Commit

Permalink
Merge pull request #888 from goetas/update-query
Browse files Browse the repository at this point in the history
Use executeUpdate instead of executeQuery for write operation
  • Loading branch information
alcaeus authored Dec 5, 2019
2 parents b5d7611 + 595489b commit b13df49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Doctrine/Migrations/Version/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit b13df49

Please sign in to comment.