Skip to content

Commit 5d755a7

Browse files
committed
rename _start_session()
1 parent 04881d6 commit 5d755a7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

django_mongodb_backend/base.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,30 @@ 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+
# 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.
222227
if not self.features.supports_transactions:
223228
return
224-
self._start_session()
229+
self._start_transaction()
225230

226231
def _set_autocommit(self, autocommit, force_begin_transaction_with_broken_autocommit=False):
227232
if self.features.supports_transactions:
228233
return
234+
# Besides @transaction.atomic() (which uses
235+
# _start_transaction_under_autocommit(), disabling autocommit is
236+
# another way to start a transaction.
229237
if not autocommit:
230-
self._start_session()
238+
self._start_transaction()
231239

232240
def _close(self):
233241
# Normally called by close(), this method is also called by some tests.

0 commit comments

Comments
 (0)