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):
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
+ # 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.
222
226
if not self .features .supports_transactions :
223
227
return
224
- self ._start_session ()
228
+ self ._start_transaction ()
225
229
226
230
def _set_autocommit (self , autocommit , force_begin_transaction_with_broken_autocommit = False ):
227
231
if self .features .supports_transactions :
228
232
return
233
+ # Besides @transaction.atomic() (which uses
234
+ # _start_transaction_under_autocommit(), disabling autocommit is
235
+ # another way to start a transaction.
229
236
if not autocommit :
230
- self ._start_session ()
237
+ self ._start_transaction ()
231
238
232
239
def _close (self ):
233
240
# Normally called by close(), this method is also called by some tests.
You can’t perform that action at this time.
0 commit comments