Changes between Initial Version and Version 1 of Ticket #30005, comment 4


Ignore:
Timestamp:
Dec 4, 2018, 4:05:22 AM (6 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30005, comment 4

    initial v1  
    11I don't think the example is wrong at all as the inner `transaction.atomic` block creates a `SAVEPOINT` (because `atomic(savepoint)` defaults to `True`) and thus the connection is usable in the event of an `IntegrityError` because a rollback of the savepoint would happen.
    22
    3 What the example is trying to demonstrate is that you can still nest `transaction.atomic()` block safely if you wrap code expected to raise database error appropriately and have queries within it's context be atomic. In this case the `create_parent()` and `add_children()` calls will be executed in the same transaction because of the function decorator.
     3What the example is trying to demonstrate is that you can still nest `transaction.atomic()` block safely if you wrap code expected to raise database error appropriately and have queries within its outer context be atomic. In this case the `create_parent()` and `add_children()` calls will be executed in the same transaction because of the function decorator.
    44
    55Think of it this way, `atomic` would be completely impossible to use if you couldn't nest calls this way given each calls to the database can theoretically raise a database exception.
Back to Top