Skip to content

Commit be0f9ba

Browse files
committed
update to Django 5.2
1 parent 52af559 commit be0f9ba

File tree

6 files changed

+27
-31
lines changed

6 files changed

+27
-31
lines changed

.github/workflows/test-python.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/checkout@v4
3434
with:
3535
repository: 'mongodb-forks/django'
36-
ref: 'mongodb-5.1.x'
36+
ref: 'mongodb-5.2.x'
3737
path: 'django_repo'
3838
persist-credentials: false
3939
- name: Install system packages for Django's Python test dependencies

django_mongodb/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.1a0"
1+
__version__ = "5.2a0"
22

33
# Check Django compatibility before other imports which may fail if the
44
# wrong version of Django is installed.

django_mongodb/features.py

+20
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ class DatabaseFeatures(BaseDatabaseFeatures):
8989
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
9090
# GenericRelation.value_to_string() assumes integer pk.
9191
"contenttypes_tests.test_fields.GenericRelationTests.test_value_to_string",
92+
# Broken by https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a
93+
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
94+
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
95+
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
96+
"aggregation_regress.tests.AggregationTests.test_aggregate_fexpr",
97+
"aggregation_regress.tests.AggregationTests.test_values_list_annotation_args_ordering",
98+
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
99+
"annotations.tests.NonAggregateAnnotationTestCase.test_values_fields_annotations_order",
100+
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_and_datetime_annotations",
101+
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_list_and_datetime_annotations",
102+
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_list_and_annotations",
103+
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_with_field_and_annotation_values",
104+
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_with_two_annotated_values_list",
105+
"queries.tests.Queries1Tests.test_union_values_subquery",
106+
# pymongo.errors.WriteError: Performing an update on the path '_id'
107+
# would modify the immutable field '_id'
108+
"migrations.test_operations.OperationTests.test_composite_pk_operations",
92109
}
93110
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
94111
_django_test_expected_failures_bitwise = {
@@ -600,6 +617,9 @@ def django_test_expected_failures(self):
600617
"foreign_object.tests.MultiColumnFKTests",
601618
"foreign_object.tests.TestExtraJoinFilterQ",
602619
},
620+
"Tuple lookups are not supported.": {
621+
"foreign_object.test_tuple_lookups.TupleLookupsTests",
622+
},
603623
"Custom lookups are not supported.": {
604624
"custom_lookups.tests.BilateralTransformTests",
605625
"custom_lookups.tests.LookupTests.test_basic_lookup",

django_mongodb/lookups.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.db import NotSupportedError
2-
from django.db.models.fields.related_lookups import In, MultiColSource, RelatedIn
2+
from django.db.models.expressions import ColPairs
3+
from django.db.models.fields.related_lookups import In, RelatedIn
34
from django.db.models.lookups import (
45
BuiltinLookup,
56
FieldGetDbPrepValueIterableMixin,
@@ -34,8 +35,8 @@ def field_resolve_expression_parameter(self, compiler, connection, sql, param):
3435

3536

3637
def in_(self, compiler, connection):
37-
if isinstance(self.lhs, MultiColSource):
38-
raise NotImplementedError("MultiColSource is not supported.")
38+
if isinstance(self.lhs, ColPairs):
39+
raise NotImplementedError("ColPairs is not supported.")
3940
db_rhs = getattr(self.rhs, "_db", None)
4041
if db_rhs is not None and db_rhs != connection.alias:
4142
raise ValueError(

django_mongodb/operations.py

-22
Original file line numberDiff line numberDiff line change
@@ -179,28 +179,6 @@ def execute_sql_flush(self, tables):
179179
if not options.get("capped", False):
180180
collection.delete_many({})
181181

182-
def prep_lookup_value(self, value, field, lookup):
183-
"""
184-
Perform type-conversion on `value` before using as a filter parameter.
185-
"""
186-
if getattr(field, "rel", None) is not None:
187-
field = field.rel.get_related_field()
188-
field_kind = field.get_internal_type()
189-
190-
if lookup in ("in", "range"):
191-
return [
192-
self._prep_lookup_value(subvalue, field, field_kind, lookup) for subvalue in value
193-
]
194-
return self._prep_lookup_value(value, field, field_kind, lookup)
195-
196-
def _prep_lookup_value(self, value, field, field_kind, lookup):
197-
if value is None:
198-
return None
199-
200-
if field_kind == "DecimalField":
201-
value = self.adapt_decimalfield_value(value, field.max_digits, field.decimal_places)
202-
return value
203-
204182
def explain_query_prefix(self, format=None, **options):
205183
# Validate options.
206184
validated_options = {}

django_mongodb/query_utils.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ def process_rhs(node, compiler, connection):
4242
value = value[0]
4343
if hasattr(node, "prep_lookup_value_mongo"):
4444
value = node.prep_lookup_value_mongo(value)
45-
# No need to prepare expressions like F() objects.
46-
if hasattr(rhs, "resolve_expression"):
47-
return value
48-
return connection.ops.prep_lookup_value(value, node.lhs.output_field, node.lookup_name)
45+
return value
4946

5047

5148
def regex_match(field, regex_vals, insensitive=False):

0 commit comments

Comments
 (0)