Skip to content

Commit

Permalink
update to Django 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Dec 20, 2024
1 parent 52af559 commit be0f9ba
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'mongodb-forks/django'
ref: 'mongodb-5.1.x'
ref: 'mongodb-5.2.x'
path: 'django_repo'
persist-credentials: false
- name: Install system packages for Django's Python test dependencies
Expand Down
2 changes: 1 addition & 1 deletion django_mongodb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "5.1a0"
__version__ = "5.2a0"

# Check Django compatibility before other imports which may fail if the
# wrong version of Django is installed.
Expand Down
20 changes: 20 additions & 0 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
# GenericRelation.value_to_string() assumes integer pk.
"contenttypes_tests.test_fields.GenericRelationTests.test_value_to_string",
# Broken by https://github.com/django/django/commit/65ad4ade74dc9208b9d686a451cd6045df0c9c3a
"aggregation.tests.AggregateTestCase.test_even_more_aggregate",
"aggregation.tests.AggregateTestCase.test_grouped_annotation_in_group_by",
"aggregation.tests.AggregateTestCase.test_non_grouped_annotation_not_in_group_by",
"aggregation_regress.tests.AggregationTests.test_aggregate_fexpr",
"aggregation_regress.tests.AggregationTests.test_values_list_annotation_args_ordering",
"annotations.tests.NonAggregateAnnotationTestCase.test_annotation_subquery_and_aggregate_values_chaining",
"annotations.tests.NonAggregateAnnotationTestCase.test_values_fields_annotations_order",
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_and_datetime_annotations",
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_list_and_datetime_annotations",
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_multiple_models_with_values_list_and_annotations",
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_with_field_and_annotation_values",
"queries.test_qs_combinators.QuerySetSetOperationTests.test_union_with_two_annotated_values_list",
"queries.tests.Queries1Tests.test_union_values_subquery",
# pymongo.errors.WriteError: Performing an update on the path '_id'
# would modify the immutable field '_id'
"migrations.test_operations.OperationTests.test_composite_pk_operations",
}
# $bitAnd, #bitOr, and $bitXor are new in MongoDB 6.3.
_django_test_expected_failures_bitwise = {
Expand Down Expand Up @@ -600,6 +617,9 @@ def django_test_expected_failures(self):
"foreign_object.tests.MultiColumnFKTests",
"foreign_object.tests.TestExtraJoinFilterQ",
},
"Tuple lookups are not supported.": {
"foreign_object.test_tuple_lookups.TupleLookupsTests",
},
"Custom lookups are not supported.": {
"custom_lookups.tests.BilateralTransformTests",
"custom_lookups.tests.LookupTests.test_basic_lookup",
Expand Down
7 changes: 4 additions & 3 deletions django_mongodb/lookups.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import NotSupportedError
from django.db.models.fields.related_lookups import In, MultiColSource, RelatedIn
from django.db.models.expressions import ColPairs
from django.db.models.fields.related_lookups import In, RelatedIn
from django.db.models.lookups import (
BuiltinLookup,
FieldGetDbPrepValueIterableMixin,
Expand Down Expand Up @@ -34,8 +35,8 @@ def field_resolve_expression_parameter(self, compiler, connection, sql, param):


def in_(self, compiler, connection):
if isinstance(self.lhs, MultiColSource):
raise NotImplementedError("MultiColSource is not supported.")
if isinstance(self.lhs, ColPairs):
raise NotImplementedError("ColPairs is not supported.")
db_rhs = getattr(self.rhs, "_db", None)
if db_rhs is not None and db_rhs != connection.alias:
raise ValueError(
Expand Down
22 changes: 0 additions & 22 deletions django_mongodb/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,6 @@ def execute_sql_flush(self, tables):
if not options.get("capped", False):
collection.delete_many({})

def prep_lookup_value(self, value, field, lookup):
"""
Perform type-conversion on `value` before using as a filter parameter.
"""
if getattr(field, "rel", None) is not None:
field = field.rel.get_related_field()
field_kind = field.get_internal_type()

if lookup in ("in", "range"):
return [
self._prep_lookup_value(subvalue, field, field_kind, lookup) for subvalue in value
]
return self._prep_lookup_value(value, field, field_kind, lookup)

def _prep_lookup_value(self, value, field, field_kind, lookup):
if value is None:
return None

if field_kind == "DecimalField":
value = self.adapt_decimalfield_value(value, field.max_digits, field.decimal_places)
return value

def explain_query_prefix(self, format=None, **options):
# Validate options.
validated_options = {}
Expand Down
5 changes: 1 addition & 4 deletions django_mongodb/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ def process_rhs(node, compiler, connection):
value = value[0]
if hasattr(node, "prep_lookup_value_mongo"):
value = node.prep_lookup_value_mongo(value)
# No need to prepare expressions like F() objects.
if hasattr(rhs, "resolve_expression"):
return value
return connection.ops.prep_lookup_value(value, node.lhs.output_field, node.lookup_name)
return value


def regex_match(field, regex_vals, insensitive=False):
Expand Down

0 comments on commit be0f9ba

Please sign in to comment.