Changes between Initial Version and Version 1 of Ticket #30005, comment 4
- Timestamp:
- Dec 4, 2018, 4:05:22 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30005, comment 4
initial v1 1 1 I 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. 2 2 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 'scontext be atomic. In this case the `create_parent()` and `add_children()` calls will be executed in the same transaction because of the function decorator.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 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. 4 4 5 5 Think 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.