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):
36
36
supports_temporal_subtraction = True
37
37
# MongoDB stores datetimes in UTC.
38
38
supports_timezones = False
39
- # Not implemented: https://github.com/mongodb/django-mongodb-backend/issues/7
40
- supports_transactions = False
41
39
supports_unspecified_pk = True
42
40
uses_savepoints = False
43
41
@@ -97,6 +95,22 @@ class DatabaseFeatures(BaseDatabaseFeatures):
97
95
"expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or" ,
98
96
}
99
97
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
+
100
114
@cached_property
101
115
def django_test_expected_failures (self ):
102
116
expected_failures = super ().django_test_expected_failures
You can’t perform that action at this time.
0 commit comments