diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 6aa2020ca..f0b010b84 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -69,10 +69,10 @@ tasks: buildvariants: - name: tests-5-noauth-nossl - display_name: Run Tests 5.0 NoAuth NoSSL + display_name: Run Tests 6.0 NoAuth NoSSL run_on: rhel87-small expansions: - MONGODB_VERSION: "5.0" + MONGODB_VERSION: "6.0" TOPOLOGY: server AUTH: "noauth" SSL: "nossl" @@ -80,10 +80,10 @@ buildvariants: - name: run-tests - name: tests-5-auth-ssl - display_name: Run Tests 5.0 Auth SSL + display_name: Run Tests 6.0 Auth SSL run_on: rhel87-small expansions: - MONGODB_VERSION: "5.0" + MONGODB_VERSION: "6.0" TOPOLOGY: server AUTH: "auth" SSL: "ssl" diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 72ca4cd8c..5aadeac0a 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -52,6 +52,6 @@ jobs: - name: Start MongoDB uses: supercharge/mongodb-github-action@1.12.0 with: - mongodb-version: 5.0 + mongodb-version: 6.0 - name: Run tests run: python3 django_repo/tests/runtests_.py diff --git a/django_mongodb_backend/features.py b/django_mongodb_backend/features.py index 59f867e09..303393b20 100644 --- a/django_mongodb_backend/features.py +++ b/django_mongodb_backend/features.py @@ -1,11 +1,9 @@ -import operator - from django.db.backends.base.features import BaseDatabaseFeatures from django.utils.functional import cached_property class DatabaseFeatures(BaseDatabaseFeatures): - minimum_database_version = (5, 0) + minimum_database_version = (6, 0) allow_sliced_subqueries_with_in = False allows_multiple_constraints_on_same_fields = False can_create_inline_fk = False @@ -24,10 +22,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): supports_expression_indexes = False supports_foreign_keys = False supports_ignore_conflicts = False - # Before MongoDB 6.0, $in cannot be used in partialFilterExpression. - supports_in_index_operator = property(operator.attrgetter("is_mongodb_6_0")) - # Before MongoDB 6.0, $or cannot be used in partialFilterExpression. - supports_or_index_operator = property(operator.attrgetter("is_mongodb_6_0")) supports_json_field_contains = False # BSON Date type doesn't support microsecond precision. supports_microsecond_precision = False @@ -97,16 +91,11 @@ class DatabaseFeatures(BaseDatabaseFeatures): "expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_right_null", "expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or", } - _django_test_expected_failures_partial_expression_in = { - "schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index", - } @cached_property def django_test_expected_failures(self): expected_failures = super().django_test_expected_failures expected_failures.update(self._django_test_expected_failures) - if not self.supports_in_index_operator: - expected_failures.update(self._django_test_expected_failures_partial_expression_in) if not self.is_mongodb_6_3: expected_failures.update(self._django_test_expected_failures_bitwise) return expected_failures @@ -601,10 +590,6 @@ def django_test_expected_failures(self): }, } - @cached_property - def is_mongodb_6_0(self): - return self.connection.get_database_version() >= (6, 0) - @cached_property def is_mongodb_6_3(self): return self.connection.get_database_version() >= (6, 3) diff --git a/django_mongodb_backend/indexes.py b/django_mongodb_backend/indexes.py index 0fc6646b2..567cd4070 100644 --- a/django_mongodb_backend/indexes.py +++ b/django_mongodb_backend/indexes.py @@ -1,6 +1,5 @@ from django.db import NotSupportedError from django.db.models import Index -from django.db.models.fields.related_lookups import In from django.db.models.lookups import BuiltinLookup from django.db.models.sql.query import Query from django.db.models.sql.where import AND, XOR, WhereNode @@ -37,20 +36,12 @@ def builtin_lookup_idx(self, compiler, connection): return {lhs_mql: {operator: value}} -def in_idx(self, compiler, connection): - if not connection.features.supports_in_index_operator: - raise NotSupportedError("MongoDB < 6.0 does not support the 'in' lookup in indexes.") - return builtin_lookup_idx(self, compiler, connection) - - def where_node_idx(self, compiler, connection): if self.connector == AND: operator = "$and" elif self.connector == XOR: raise NotSupportedError("MongoDB does not support the '^' operator lookup in indexes.") else: - if not connection.features.supports_in_index_operator: - raise NotSupportedError("MongoDB < 6.0 does not support the '|' operator in indexes.") operator = "$or" if self.negated: raise NotSupportedError("MongoDB does not support the '~' operator in indexes.") @@ -69,6 +60,5 @@ def where_node_idx(self, compiler, connection): def register_indexes(): BuiltinLookup.as_mql_idx = builtin_lookup_idx - In.as_mql_idx = in_idx Index._get_condition_mql = _get_condition_mql WhereNode.as_mql_idx = where_node_idx diff --git a/tests/indexes_/test_condition.py b/tests/indexes_/test_condition.py index f0d67b36b..b5b02e9b3 100644 --- a/tests/indexes_/test_condition.py +++ b/tests/indexes_/test_condition.py @@ -2,7 +2,7 @@ from django.db import NotSupportedError, connection from django.db.models import Index, Q -from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature +from django.test import TestCase from .models import Article @@ -46,26 +46,6 @@ def test_xor_not_supported(self): condition=Q(pk=True) ^ Q(pk=False), )._get_condition_mql(Article, schema_editor=editor) - @skipIfDBFeature("supports_or_index_operator") - def test_or_not_supported(self): - msg = "MongoDB < 6.0 does not support the '|' operator in indexes." - with self.assertRaisesMessage(NotSupportedError, msg), connection.schema_editor() as editor: - Index( - name="test", - fields=["headline"], - condition=Q(pk=True) | Q(pk=False), - )._get_condition_mql(Article, schema_editor=editor) - - @skipIfDBFeature("supports_in_index_operator") - def test_in_not_supported(self): - msg = "MongoDB < 6.0 does not support the 'in' lookup in indexes." - with self.assertRaisesMessage(NotSupportedError, msg), connection.schema_editor() as editor: - Index( - name="test", - fields=["headline"], - condition=Q(pk__in=[True]), - )._get_condition_mql(Article, schema_editor=editor) - def test_operations(self): operators = ( ("gt", "$gt"), @@ -86,7 +66,6 @@ def test_operations(self): ) self.assertAddRemoveIndex(editor, Article, index) - @skipUnlessDBFeature("supports_in_index_operator") def test_composite_index(self): with connection.schema_editor() as editor: index = Index( @@ -110,8 +89,6 @@ def test_composite_op_index(self): (operator.or_, "$or"), (operator.and_, "$and"), ) - if not connection.features.supports_or_index_operator: - operators = operators[1:] for op, mongo_operator in operators: with self.subTest(operator=op), connection.schema_editor() as editor: index = Index(