Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31423 closed Cleanup/optimization (fixed)

Clarify using nested database transactions in atomic() docs.

Reported by: AxeOfMen Owned by: Simon Charette
Component: Documentation Version: 3.0
Severity: Normal Keywords: documentation transaction atomic
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

There is an example on the transactions documentation page of using the atomic context manager in a try/except block. The example uses both the atomic context manager and decorator. Is this intentional? If so, text describing the intent and purpose of using both would be appropriate. My guess is that it is unintentional and that the decorator should be removed.

https://github.com/django/django/blob/master/docs/topics/db/transactions.txt#L134

Change History (4)

comment:2 by Simon Charette, 4 years ago

I think usage of both is a view decorator and a context manager is intentional

In this example, even if generate_relationships() causes a database error by breaking an integrity constraint, you can execute queries in add_children(), and the changes from create_parent() are still there.

Maybe the text could be augmented with ... are still there and bound to the same transaction. to denote that both changes would be committed or rolled back as a unit.

Last edited 4 years ago by Simon Charette (previous) (diff)

comment:3 by Mariusz Felisiak, 4 years ago

Has patch: set
Owner: changed from nobody to Simon Charette
Status: newassigned
Summary: Transactions documentation errorClarify using nested database transactions in atomic() docs.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Yes this is intentional. Clarification proposed by Simon looks good to me.

PR

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 810f18c2:

[3.0.x] Fixed #31423 -- Clarified nested atomic() example.

Backport of fa5e7e46d875d4143510944f19d79df7b1739bab from master

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In fa5e7e46:

Fixed #31423 -- Clarified nested atomic() example.

Note: See TracTickets for help on using tickets.
Back to Top