Opened 3 years ago

Closed 3 years ago

#19154 closed Cleanup/optimization (fixed)

TransactionManagementError raised when data is not changed

Reported by: als 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 timo 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by claudep

  • Component changed from Uncategorized to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Cleanup/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 3 years ago by timo

comment:2 Changed 3 years ago by timo

  • Has patch set

comment:3 Changed 3 years ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 3 years ago by timo

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top