-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Use executeUpdate instead of executeQuery for write operation #888
Conversation
goetas
commented
Dec 5, 2019
Q | A |
---|---|
Type | improvement |
BC Break | no |
Fixed issues |
a11bddb
to
595489b
Compare
Woops, I rebased the wrong PR… does not look like it changed anything though… EDIT: they're the same code, that's why 😅 |
Thanks @goetas! |
Hello. Sorry, I'm super late on this one, but It breaks my application. The error:
Then, the So I simply propose to revert this PR since it does not improve (as state in the PR description) nothing (I don't want to be harsh!) I'm gonna do a PR |
Using |
@stof Ah! I did not know that. But the migrations is already wrapped in a Transaction, isn't? It's the case on PG at least. I don't use so much MySQL, so I don't know |
This is done by default. But there are ways to disable that wrapping in doctrine/migrations (no idea why you would want to do that though, as I remember my pain when dealing with buggy migrations years ago before switching from MySQL to PG) |
ok, so let's merge my PR :) |
@lyrixx I'd like to understand what's going on here… is the mysql driver complaining that we are trying to run When I read that comment, I think that the right way to justify a revert would be to show that the query that causes the issue is has a different type from the queries described in https://github.com/doctrine/dbal/blob/3622d6d5823ccaba5d768c311aed27383655041f/lib/Doctrine/DBAL/Connection.php#L1419-L1423 I think that's the case for
If you agree with that explanation, please add it to your commit message, and please add a comment in the code telling people not to change this to |
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
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. ``` Moreover, `executeUpdate` is deprecated
- Total issues resolved: **0** - Total pull requests resolved: **6** - Total contributors: **6** - [1032: Let composer decide the best version](#1032) thanks to @PowerKiKi - [1020: Add badges into README about license and packagist](#1020) thanks to @matks - [999: Allow using on PHP 7.1 with Composer 2](#999) thanks to @nicolas-grekas - [981: Add "from-empty-schema" option for "diff" command](#981) thanks to @guilliamxavier - [954: Make compared tables order idempotent](#954) thanks to @julienfalque - [888: Use executeUpdate instead of executeQuery for write operation](#888) thanks to @goetas
- Total issues resolved: **0** - Total pull requests resolved: **6** - Total contributors: **6** - [1032: Let composer decide the best version](#1032) thanks to @PowerKiKi - [1020: Add badges into README about license and packagist](#1020) thanks to @matks - [999: Allow using on PHP 7.1 with Composer 2](#999) thanks to @nicolas-grekas - [981: Add "from-empty-schema" option for "diff" command](#981) thanks to @guilliamxavier - [954: Make compared tables order idempotent](#954) thanks to @julienfalque - [888: Use executeUpdate instead of executeQuery for write operation](#888) thanks to @goetas
- Total issues resolved: **0** - Total pull requests resolved: **6** - Total contributors: **6** - [1032: Let composer decide the best version](#1032) thanks to @PowerKiKi - [1020: Add badges into README about license and packagist](#1020) thanks to @matks - [999: Allow using on PHP 7.1 with Composer 2](#999) thanks to @nicolas-grekas - [981: Add "from-empty-schema" option for "diff" command](#981) thanks to @guilliamxavier - [954: Make compared tables order idempotent](#954) thanks to @julienfalque - [888: Use executeUpdate instead of executeQuery for write operation](#888) thanks to @goetas