Skip to content

Commit

Permalink
Revert "Merge pull request #888 from goetas/update-query"
Browse files Browse the repository at this point in the history
from: https://dev.mysql.com/doc/refman/8.0/en/repair-table.html

> REPAIR TABLE returns a result set with the columns shown in the
following table.

That's why doctrine/migrations should not use `executeUpdate`, because
results are not read. So the user can end with the following errors

```
  SQLSTATE[HY000]: General error: 2014 Cannot execute queries while
other unbuffered queries are active.  Consider using
PDOStatement::fetchAll().  Alternatively, if your code is only ever
going to run against mysql, you may enable query buffering by
setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
```

More over, `executeUpdate` is deprecated
  • Loading branch information
lyrixx committed Nov 6, 2020
1 parent 100e85a commit 4d8185d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
5 changes: 3 additions & 2 deletions lib/Doctrine/Migrations/Version/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,11 @@ private function executeVersionExecutionResult(

$this->outputSqlQuery($key, $query);

// Do not use method that returns results here, to not block next queries
if (! isset($this->params[$key])) {
$this->connection->executeUpdate($query);
$this->connection->executeQuery($query);
} else {
$this->connection->executeUpdate($query, $this->params[$key], $this->types[$key]);
$this->connection->executeQuery($query, $this->params[$key], $this->types[$key]);
}

$stopwatchEvent->stop();
Expand Down
20 changes: 0 additions & 20 deletions tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,6 @@ 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 4d8185d

Please sign in to comment.