Skip to content

Commit 25eeef8

Browse files
committed
remove storage engine checks
1 parent 2ffbaeb commit 25eeef8

File tree

3 files changed

+8
-45
lines changed

3 files changed

+8
-45
lines changed

django_mongodb_backend/features.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -616,16 +616,11 @@ def supports_select_union(self):
616616
@cached_property
617617
def supports_transactions(self):
618618
"""
619-
Transactions are enabled if the MongoDB configuration supports it:
620-
MongoDB must be configured as a replica set or sharded cluster, and
621-
the store engine must be WiredTiger.
619+
Transactions are enabled if MongoDB is configured as a replica set or a
620+
sharded cluster.
622621
"""
623622
self.connection.ensure_connection()
624623
client = self.connection.connection.admin
625-
hello_response = client.command("hello")
626-
is_replica_set = "setName" in hello_response
627-
is_sharded_cluster = hello_response.get("msg") == "isdbgrid"
628-
if is_replica_set or is_sharded_cluster:
629-
engine = client.command("serverStatus").get("storageEngine", {})
630-
return engine.get("name") == "wiredTiger"
631-
return False
624+
hello = client.command("hello")
625+
# a replica set or a sharded cluster
626+
return "setName" in hello or hello.get("msg") == "isdbgrid"

docs/source/ref/database.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ Transactions
5050
.. versionadded:: 5.2.0b2
5151

5252
Support for :doc:`Django's transactions APIs <django:topics/db/transactions>`
53-
is enabled if the MongoDB configuration supports them: MongoDB must be
54-
configured as a :doc:`replica set <manual:replication>` or :doc:`sharded
55-
cluster <manual:sharding>`, and the store engine must be :doc:`WiredTiger
56-
<manual:core/wiredtiger>`.
53+
is enabled if MongoDB is configured as a :doc:`replica set<manual:replication>`
54+
or a :doc:`sharded cluster <manual:sharding>`.
5755

5856
If transactions aren't supported, query execution uses Django and MongoDB's
5957
default behavior of autocommit mode. Each query is immediately committed to the

tests/backend_/test_features.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,22 @@ def test_replica_set(self):
1818
def mocked_command(command):
1919
if command == "hello":
2020
return {"setName": "foo"}
21-
if command == "serverStatus":
22-
return {"storageEngine": {"name": "wiredTiger"}}
2321
raise Exception("Unexpected command")
2422

2523
with patch("pymongo.synchronous.database.Database.command", wraps=mocked_command):
2624
self.assertIs(connection.features.supports_transactions, True)
2725

28-
def test_replica_set_other_storage_engine(self):
29-
"""No support on a non-wiredTiger replica set."""
30-
31-
def mocked_command(command):
32-
if command == "hello":
33-
return {"setName": "foo"}
34-
if command == "serverStatus":
35-
return {"storageEngine": {"name": "other"}}
36-
raise Exception("Unexpected command")
37-
38-
with patch("pymongo.synchronous.database.Database.command", wraps=mocked_command):
39-
self.assertIs(connection.features.supports_transactions, False)
40-
4126
def test_sharded_cluster(self):
42-
"""A sharded cluster with wiredTiger storage engine supports them."""
27+
"""A sharded cluster supports transactions."""
4328

4429
def mocked_command(command):
4530
if command == "hello":
4631
return {"msg": "isdbgrid"}
47-
if command == "serverStatus":
48-
return {"storageEngine": {"name": "wiredTiger"}}
4932
raise Exception("Unexpected command")
5033

5134
with patch("pymongo.synchronous.database.Database.command", wraps=mocked_command):
5235
self.assertIs(connection.features.supports_transactions, True)
5336

54-
def test_sharded_cluster_other_storage_engine(self):
55-
"""No support on a non-wiredTiger shared cluster."""
56-
57-
def mocked_command(command):
58-
if command == "hello":
59-
return {"msg": "isdbgrid"}
60-
if command == "serverStatus":
61-
return {"storageEngine": {"name": "other"}}
62-
raise Exception("Unexpected command")
63-
64-
with patch("pymongo.synchronous.database.Database.command", wraps=mocked_command):
65-
self.assertIs(connection.features.supports_transactions, False)
66-
6737
def test_no_support(self):
6838
"""No support on a non-replica set, non-sharded cluster."""
6939

0 commit comments

Comments
 (0)