Opened 6 years ago

Closed 6 years ago

#19154 closed Cleanup/optimization (fixed)

TransactionManagementError raised when data is not changed

Reported by: alexander smishlajev Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


According to Django documentation, a commit_manually decorator would raise TransactionManagementError if decorated block changes data and doesn't commit() or rollback().

Actually, TransactionManagementError is raised when no data is changed, but some SELECT statements were executed by model managers.

If that is intended behavior, Django documentation should reflect it, but it would be better if SELECT statements could run without commit or rollback.

Attachments (1)

19154.diff (903 bytes) - added by Tim Graham 6 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 6 years ago by Claude Paroz

Component: UncategorizedDocumentation
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Yes, this is intended behaviour and the documentation should be updated. The behaviour is explicitely tested (see transactions_regress tests). You can read lengthy related discussions on #9964. It is not possible for Django to really know if data have been modified or not, as SELECT-only statements can modify data.

Changed 6 years ago by Tim Graham

Attachment: 19154.diff added

comment:2 Changed 6 years ago by Tim Graham

Has patch: set

comment:3 Changed 6 years ago by Claude Paroz

Triage Stage: AcceptedReady for checkin

comment:4 Changed 6 years ago by Tim Graham

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top