-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration fails when using SELECT queries in addSql
#1004
Comments
Found a simple fix for our specific use case: public function up(Schema $schema): void
{
- $this->addSql('SELECT "some dummy message to mute warnings"');
+ $this->addSql('-- "some dummy message to mute warnings"');
} |
That is neat! I have documented this bc break in #1006 |
This also affects |
I saw this same issue recently. If 2.2.1 changed it then what about that release made the change? https://github.com/doctrine/migrations/releases/tag/2.2.1 The error message gives the solution: "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." This isn't an error I would expect another DBMS to throw because the PDO attribute is for MySQL. So I don't see the harm in setting it even if you're using another DBMS too. PDO::setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); Can you try setting that value to see if following the error's suggestion actually works? |
I'm sorry I've expressed bad myself: everything worked in
The attribute cannot be set statically.
Even set in the right place, it doesn't work. By the way, how is this error even possible, if nowhere in the code the connection is set to unbuffered queries? |
Adding a |
This change has been reverted in #1071, and it is already in the 3.0.x branch, but not yet released |
BC Break Report
Summary
When using an SELECT query in
addSql
the migrations fails with an PDO Driver exception on MySQL 5.7 (PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
is enabled).Previous behavior
SELECT queries did not raise exception while executing the migration.
Current behavior
Execution results in PDO Driver Exception
How to reproduce
Given the following migration file:
Execute migration on MySQL 5.7 or higher:
php bin/console.php migrations:execute -n 'App\Infrastructure\Migrations\Version20200618062514'
Background
We used the
$this->addSql('SELECT 1');
to mitigate or hidewas executed but did not result in any SQL statements.
Warnings for Migrations that changed later on because of external schema changes.The underlying reason for the failure is the usage of
executeUpdate
in\Doctrine\Migrations\Version\DbalExecutor::executeResult
.This can be reproduced with the DBAL Connection:
Given this is just a workaround/hack/miss use from our side feel free to close this issue.
This issue was opened to document this behavior so it can be used for later reference.
The text was updated successfully, but these errors were encountered: