File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
3636 supports_temporal_subtraction = True
3737 # MongoDB stores datetimes in UTC.
3838 supports_timezones = False
39- # Not implemented: https://github.com/mongodb/django-mongodb-backend/issues/7
40- supports_transactions = False
4139 supports_unspecified_pk = True
4240 uses_savepoints = False
4341
@@ -97,6 +95,22 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9795 "expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or" ,
9896 }
9997
98+ @cached_property
99+ def supports_transactions (self ):
100+ """Confirm support for transactions."""
101+ is_replica_set = False
102+ is_sharded_cluster = False
103+ with self .connection .cursor ():
104+ client = self .connection .connection
105+ hello_response = client .admin .command ("hello" )
106+ if "setName" in hello_response :
107+ is_replica_set = True
108+ if "msg" in client .admin .command ("hello" ) and hello_response ["msg" ] == "isdbgrid" :
109+ is_sharded_cluster = True
110+ if is_replica_set or is_sharded_cluster :
111+ return True
112+ return False
113+
100114 @cached_property
101115 def django_test_expected_failures (self ):
102116 expected_failures = super ().django_test_expected_failures
You can’t perform that action at this time.
0 commit comments