Skip to content

Commit 4db618f

Browse files
committed
drop support for MongoDB 5.0
It was end of life in October 2024.
1 parent 6a87d84 commit 4db618f

File tree

5 files changed

+7
-55
lines changed

5 files changed

+7
-55
lines changed

.evergreen/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,21 @@ tasks:
6969

7070
buildvariants:
7171
- name: tests-5-noauth-nossl
72-
display_name: Run Tests 5.0 NoAuth NoSSL
72+
display_name: Run Tests 6.0 NoAuth NoSSL
7373
run_on: rhel87-small
7474
expansions:
75-
MONGODB_VERSION: "5.0"
75+
MONGODB_VERSION: "6.0"
7676
TOPOLOGY: server
7777
AUTH: "noauth"
7878
SSL: "nossl"
7979
tasks:
8080
- name: run-tests
8181

8282
- name: tests-5-auth-ssl
83-
display_name: Run Tests 5.0 Auth SSL
83+
display_name: Run Tests 6.0 Auth SSL
8484
run_on: rhel87-small
8585
expansions:
86-
MONGODB_VERSION: "5.0"
86+
MONGODB_VERSION: "6.0"
8787
TOPOLOGY: server
8888
AUTH: "auth"
8989
SSL: "ssl"

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ jobs:
5252
- name: Start MongoDB
5353
uses: supercharge/[email protected]
5454
with:
55-
mongodb-version: 5.0
55+
mongodb-version: 6.0
5656
- name: Run tests
5757
run: python3 django_repo/tests/runtests_.py

django_mongodb_backend/features.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import operator
2-
31
from django.db.backends.base.features import BaseDatabaseFeatures
42
from django.utils.functional import cached_property
53

64

75
class DatabaseFeatures(BaseDatabaseFeatures):
8-
minimum_database_version = (5, 0)
6+
minimum_database_version = (6, 0)
97
allow_sliced_subqueries_with_in = False
108
allows_multiple_constraints_on_same_fields = False
119
can_create_inline_fk = False
@@ -24,10 +22,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
2422
supports_expression_indexes = False
2523
supports_foreign_keys = False
2624
supports_ignore_conflicts = False
27-
# Before MongoDB 6.0, $in cannot be used in partialFilterExpression.
28-
supports_in_index_operator = property(operator.attrgetter("is_mongodb_6_0"))
29-
# Before MongoDB 6.0, $or cannot be used in partialFilterExpression.
30-
supports_or_index_operator = property(operator.attrgetter("is_mongodb_6_0"))
3125
supports_json_field_contains = False
3226
# BSON Date type doesn't support microsecond precision.
3327
supports_microsecond_precision = False
@@ -97,16 +91,11 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9791
"expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_right_null",
9892
"expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or",
9993
}
100-
_django_test_expected_failures_partial_expression_in = {
101-
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
102-
}
10394

10495
@cached_property
10596
def django_test_expected_failures(self):
10697
expected_failures = super().django_test_expected_failures
10798
expected_failures.update(self._django_test_expected_failures)
108-
if not self.supports_in_index_operator:
109-
expected_failures.update(self._django_test_expected_failures_partial_expression_in)
11099
if not self.is_mongodb_6_3:
111100
expected_failures.update(self._django_test_expected_failures_bitwise)
112101
return expected_failures
@@ -601,10 +590,6 @@ def django_test_expected_failures(self):
601590
},
602591
}
603592

604-
@cached_property
605-
def is_mongodb_6_0(self):
606-
return self.connection.get_database_version() >= (6, 0)
607-
608593
@cached_property
609594
def is_mongodb_6_3(self):
610595
return self.connection.get_database_version() >= (6, 3)

django_mongodb_backend/indexes.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.db import NotSupportedError
22
from django.db.models import Index
3-
from django.db.models.fields.related_lookups import In
43
from django.db.models.lookups import BuiltinLookup
54
from django.db.models.sql.query import Query
65
from django.db.models.sql.where import AND, XOR, WhereNode
@@ -37,20 +36,12 @@ def builtin_lookup_idx(self, compiler, connection):
3736
return {lhs_mql: {operator: value}}
3837

3938

40-
def in_idx(self, compiler, connection):
41-
if not connection.features.supports_in_index_operator:
42-
raise NotSupportedError("MongoDB < 6.0 does not support the 'in' lookup in indexes.")
43-
return builtin_lookup_idx(self, compiler, connection)
44-
45-
4639
def where_node_idx(self, compiler, connection):
4740
if self.connector == AND:
4841
operator = "$and"
4942
elif self.connector == XOR:
5043
raise NotSupportedError("MongoDB does not support the '^' operator lookup in indexes.")
5144
else:
52-
if not connection.features.supports_in_index_operator:
53-
raise NotSupportedError("MongoDB < 6.0 does not support the '|' operator in indexes.")
5445
operator = "$or"
5546
if self.negated:
5647
raise NotSupportedError("MongoDB does not support the '~' operator in indexes.")
@@ -69,6 +60,5 @@ def where_node_idx(self, compiler, connection):
6960

7061
def register_indexes():
7162
BuiltinLookup.as_mql_idx = builtin_lookup_idx
72-
In.as_mql_idx = in_idx
7363
Index._get_condition_mql = _get_condition_mql
7464
WhereNode.as_mql_idx = where_node_idx

tests/indexes_/test_condition.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.db import NotSupportedError, connection
44
from django.db.models import Index, Q
5-
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
5+
from django.test import TestCase
66

77
from .models import Article
88

@@ -46,26 +46,6 @@ def test_xor_not_supported(self):
4646
condition=Q(pk=True) ^ Q(pk=False),
4747
)._get_condition_mql(Article, schema_editor=editor)
4848

49-
@skipIfDBFeature("supports_or_index_operator")
50-
def test_or_not_supported(self):
51-
msg = "MongoDB < 6.0 does not support the '|' operator in indexes."
52-
with self.assertRaisesMessage(NotSupportedError, msg), connection.schema_editor() as editor:
53-
Index(
54-
name="test",
55-
fields=["headline"],
56-
condition=Q(pk=True) | Q(pk=False),
57-
)._get_condition_mql(Article, schema_editor=editor)
58-
59-
@skipIfDBFeature("supports_in_index_operator")
60-
def test_in_not_supported(self):
61-
msg = "MongoDB < 6.0 does not support the 'in' lookup in indexes."
62-
with self.assertRaisesMessage(NotSupportedError, msg), connection.schema_editor() as editor:
63-
Index(
64-
name="test",
65-
fields=["headline"],
66-
condition=Q(pk__in=[True]),
67-
)._get_condition_mql(Article, schema_editor=editor)
68-
6949
def test_operations(self):
7050
operators = (
7151
("gt", "$gt"),
@@ -86,7 +66,6 @@ def test_operations(self):
8666
)
8767
self.assertAddRemoveIndex(editor, Article, index)
8868

89-
@skipUnlessDBFeature("supports_in_index_operator")
9069
def test_composite_index(self):
9170
with connection.schema_editor() as editor:
9271
index = Index(
@@ -110,8 +89,6 @@ def test_composite_op_index(self):
11089
(operator.or_, "$or"),
11190
(operator.and_, "$and"),
11291
)
113-
if not connection.features.supports_or_index_operator:
114-
operators = operators[1:]
11592
for op, mongo_operator in operators:
11693
with self.subTest(operator=op), connection.schema_editor() as editor:
11794
index = Index(

0 commit comments

Comments
 (0)