Documentation: db transactions clarification
|Reported by:||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In section https://docs.djangoproject.com/en/dev/topics/db/transactions/#requirements-for-transaction-handling says "Django requires that every transaction that is opened is closed before the completion of a request. If you are using autocommit() (the default commit mode) or commit_on_success(), this will be done for you automatically.", giving the impression that given the autocommit we never need to perform commits, but this is not correct for the case of writing raw sql inserts, as explained in https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly "After performing a data changing operation, you should then call transaction.commit_unless_managed() to ensure your changes are committed to the database".
Just for clarification I suggest adding in the #requirements-for-transaction-handling a sentence mentioning the need for manually committing for raw sql inserts and/or linking to the executing-custom-sql-directly section.
Change History (14)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|