mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #24921 -- set_autocommit(False) + ORM queries.
This commits lifts the restriction that the outermost atomic block must be declared with savepoint=False. This restriction was overly cautious. The logic that makes it safe not to create savepoints for inner blocks also applies to the outermost block when autocommit is disabled and a transaction is already active. This makes it possible to use the ORM after set_autocommit(False). Previously it didn't work because ORM write operations are protected with atomic(savepoint=False).
This commit is contained in:
parent
361254810e
commit
91e9f1c972
4 changed files with 25 additions and 11 deletions
|
@ -46,3 +46,7 @@ Bugfixes
|
|||
|
||||
* Readded inline foreign keys to form instances when validating model formsets
|
||||
(:ticket:`25431`).
|
||||
|
||||
* Allowed using ORM write methods after disabling autocommit with
|
||||
:func:`set_autocommit(False) <django.db.transaction.set_autocommit>`
|
||||
(:ticket:`24921`).
|
||||
|
|
|
@ -200,8 +200,12 @@ Django provides a single API to control database transactions.
|
|||
the error handling described above.
|
||||
|
||||
You may use ``atomic`` when autocommit is turned off. It will only use
|
||||
savepoints, even for the outermost block, and it will raise an exception
|
||||
if the outermost block is declared with ``savepoint=False``.
|
||||
savepoints, even for the outermost block.
|
||||
|
||||
.. versionchanged:: 1.8.5
|
||||
|
||||
Previously the outermost atomic block couldn't be declared with
|
||||
``savepoint=False`` when autocommit was turned off.
|
||||
|
||||
.. admonition:: Performance considerations
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue