dbal
dbal copied to clipboard
Fix incorrect `transactional()` handling when DB auto-rolled back the transaction
trafficstars
| Q | A |
|---|---|
| Type | bug |
| Fixed issues | #3423 |
Summary
https://github.com/doctrine/dbal/pull/6543 partially solved what we tried to achieve in https://github.com/doctrine/dbal/pull/4846. With that There's no active transaction exception contains the actual exception in $previous.
Now, let's get rid of There's no active transaction exception which occurs e.g. when using deferred constraints so the violation is checked at the end of the transaction and not during it. Database then rolls back the transaction automatically.
The current faulty flow is following:
- on
commit(), Constrain violation occurs - transaction is implicitly aborted and rolled back in database
- DBAL calls
rollback() - Since there's no active transaction,
There's no active transactionexception is thrown:
This PR adjusts the flow so:
- on
commit(), Constrain violation occurs - transaction is implicitly aborted and rolled back in database
- DBAL DOES NOT call
rollback()🥳
For DBAL v4 it looks like this https://github.com/doctrine/dbal/pull/6546 (draft, does not contain review changes)