-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Why do you begin a transaction in your commit method?! #6258
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Ah actually, the second code block is in |
And to answer your question, this is done in auto-commit mode: https://www.doctrine-project.org/projects/doctrine-dbal/en/3.7/reference/transactions.html#auto-commit-mode The new transaction is not nested, since we are inside |
cod done? |
But why do you begin transactions in the commit method? I haven't found an answer about the purpose in the doc. |
Sorry, I think I meant to wrote "this is done when not in auto-commit mode". When in auto-commit mode, there are no transactions at all => everything is committed to the database as soon as it sent. |
But it can guess when I need to open a new one 🤔
Current behaviour just mimics autocommit behaviour in databases, but consequently (in the case where autocommit = off) usage of transactional methods becomes pointless (because anyway, we will need to perform an additional commit and also there will probably be unnecessary nested transactions) and transactions demarcation instead of becoming explicit, stays implicit, but in a different way in comparison to autocommit = on 😁 |
Bug Report
Using Doctrine 3.7.2 and Symfony 6.3.
Summary
In the EntityManager.php file, we have the
wrapInTransaction
method:https://github.com/doctrine/orm/blob/e585a92763612455f591b44cf0482d9852cc5fc0/lib/Doctrine/ORM/EntityManager.php#L267-L284
Inside the code of
$this->conn->commit()
we can find that at the very end of the method:dbal/src/Connection.php
Lines 1442 to 1448 in 6a793fb
Why to declare a nested transaction at the end without ever closing it?
Current behaviour
I noticed that when I run my integration tests, warning about "Nested Transactions..."
I was "forced" to declare "use_savepoints: true" in my doctrine.yaml.
How to reproduce
Don't declare use_savepoints: true in doctrine.yaml and run an integration test using
wrapInTransaction
.Expected behaviour
Don't declare a useless nested transaction.
The text was updated successfully, but these errors were encountered: