@@ -212,22 +212,30 @@ def _rollback(self):
212
212
self .session .abort_transaction ()
213
213
self .session = None
214
214
215
- def _start_session (self ):
215
+ def _start_transaction (self ):
216
216
if self .session is None :
217
217
self .session = self .connection .start_session ()
218
218
with debug_transaction (self , "session.start_transaction()" ):
219
219
self .session .start_transaction ()
220
220
221
221
def _start_transaction_under_autocommit (self ):
222
+ # Implementing this hook (intended only for SQLite), allows
223
+ # BaseDatabaseWrapper.set_autocommit() to use it to start a transaction
224
+ # rather than set_autocommit(), bypassing set_autocommit()'s call to
225
+ # debug_transaction(self, "BEGIN") which isn't semantic for a no-SQL
226
+ # backend.
222
227
if not self .features .supports_transactions :
223
228
return
224
- self ._start_session ()
229
+ self ._start_transaction ()
225
230
226
231
def _set_autocommit (self , autocommit , force_begin_transaction_with_broken_autocommit = False ):
227
232
if self .features .supports_transactions :
228
233
return
234
+ # Besides @transaction.atomic() (which uses
235
+ # _start_transaction_under_autocommit(), disabling autocommit is
236
+ # another way to start a transaction.
229
237
if not autocommit :
230
- self ._start_session ()
238
+ self ._start_transaction ()
231
239
232
240
def _close (self ):
233
241
# Normally called by close(), this method is also called by some tests.
0 commit comments