File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -212,22 +212,29 @@ def _rollback(self):
212212 self .session .abort_transaction ()
213213 self .session = None
214214
215- def _start_session (self ):
215+ def _start_transaction (self ):
216216 if self .session is None :
217217 self .session = self .connection .start_session ()
218218 with debug_transaction (self , "session.start_transaction()" ):
219219 self .session .start_transaction ()
220220
221221 def _start_transaction_under_autocommit (self ):
222+ # Using this method instead of _set_autocommit()) to start a
223+ # transaction bypasses BaseDatabaseWrapper.set_autocommit()'s
224+ # debug_transaction(self, "BEGIN") which is appropriate for a no-SQL
225+ # backend.
222226 if not self .features .supports_transactions :
223227 return
224- self ._start_session ()
228+ self ._start_transaction ()
225229
226230 def _set_autocommit (self , autocommit , force_begin_transaction_with_broken_autocommit = False ):
227231 if self .features .supports_transactions :
228232 return
233+ # Besides @transaction.atomic() (which uses
234+ # _start_transaction_under_autocommit(), disabling autocommit is
235+ # another way to start a transaction.
229236 if not autocommit :
230- self ._start_session ()
237+ self ._start_transaction ()
231238
232239 def _close (self ):
233240 # Normally called by close(), this method is also called by some tests.
You can’t perform that action at this time.
0 commit comments