Skip to content

Commit

Permalink
update to Django 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Aug 23, 2024
1 parent 2d96786 commit 62b819e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'mongodb-forks/django'
ref: 'mongodb-5.0.x'
ref: 'mongodb-5.1.x'
path: 'django_repo'
- name: Install system packages for Django's Python test dependencies
run: |
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.0a0"
__version__ = "5.1a0"

# Check Django compatibility before other imports which may fail if the
# wrong version of Django is installed.
Expand Down
4 changes: 2 additions & 2 deletions django_mongodb/aggregates.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import deepcopy

from django.db.models.aggregates import Aggregate, Count, StdDev, Variance
from django.db.models.expressions import Case, Value, When
from django.db.models.expressions import Case, Col, Value, When
from django.db.models.lookups import IsNull
from django.db.models.sql.where import WhereNode

Expand All @@ -19,7 +19,7 @@ def aggregate(
resolve_inner_expression=False,
**extra_context, # noqa: ARG001
):
if self.filter:
if self.filter and not isinstance(self.filter, Col):
node = self.copy()
node.filter = None
source_expressions = node.get_source_expressions()
Expand Down
15 changes: 14 additions & 1 deletion django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class DatabaseFeatures(BaseDatabaseFeatures):
uses_savepoints = False

_django_test_expected_failures = {
# $concat only supports strings, not int
"db_functions.text.test_concat.ConcatTests.test_concat_non_str",
# QuerySet.order_by() with annotation transform doesn't work:
# "Expression $mod takes exactly 2 arguments. 1 were passed in"
# https://github.com/django/django/commit/b0ad41198b3e333f57351e3fce5a1fb47f23f376
"aggregation.tests.AggregateTestCase.test_order_by_aggregate_transform",
# Database defaults not supported: bson.errors.InvalidDocument:
# cannot encode object: <django.db.models.expressions.DatabaseDefault
"basic.tests.ModelInstanceCreationTests.test_save_primary_with_db_default",
Expand All @@ -51,7 +57,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# Length of null considered zero rather than null.
"db_functions.text.test_length.LengthTests.test_basic",
# range lookup includes incorrect values.
"expressions.tests.IterableLookupInnerExpressionsTests.test_expressions_in_lookups_join_choice",
"expressions.tests.IterableLookupInnerExpressionsTests.test_expressions_range_lookups_join_choice",
# Unexpected alias_refcount in alias_map.
"queries.tests.Queries1Tests.test_order_by_tables",
# The $sum aggregation returns 0 instead of None for null.
Expand Down Expand Up @@ -117,6 +123,7 @@ def django_test_expected_failures(self):
"QuerySet.prefetch_related() is not supported on MongoDB.": {
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_proxied",
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_reverse_proxied",
"many_to_many.tests.ManyToManyQueryTests.test_prefetch_related_no_queries_optimization_disabled",
"many_to_many.tests.ManyToManyTests.test_add_after_prefetch",
"many_to_many.tests.ManyToManyTests.test_add_then_remove_after_prefetch",
"many_to_many.tests.ManyToManyTests.test_clear_after_prefetch",
Expand Down Expand Up @@ -178,6 +185,7 @@ def django_test_expected_failures(self):
"expressions.tests.BasicExpressionsTests.test_case_in_filter_if_boolean_output_field",
"expressions.tests.BasicExpressionsTests.test_exists_in_filter",
"expressions.tests.BasicExpressionsTests.test_order_by_exists",
"expressions.tests.BasicExpressionsTests.test_slicing_of_outerref",
"expressions.tests.BasicExpressionsTests.test_subquery",
"expressions.tests.ExistsTests.test_filter_by_empty_exists",
"expressions.tests.ExistsTests.test_negated_empty_exists",
Expand Down Expand Up @@ -298,6 +306,7 @@ def django_test_expected_failures(self):
"queries.tests.EmptyQuerySetTests.test_values_subquery",
"queries.tests.ExcludeTests.test_exclude_subquery",
"queries.tests.NullInExcludeTest.test_null_in_exclude_qs",
"queries.tests.Queries1Tests.test_combining_does_not_mutate",
"queries.tests.Queries1Tests.test_ticket9985",
"queries.tests.Queries1Tests.test_ticket9997",
"queries.tests.Queries1Tests.test_ticket10742",
Expand Down Expand Up @@ -414,7 +423,11 @@ def django_test_expected_failures(self):
"aggregation.tests.AggregateTestCase.test_count_star",
"delete.tests.DeletionTests.test_only_referenced_fields_selected",
"lookup.tests.LookupTests.test_in_ignore_none",
"lookup.tests.LookupTests.test_lookup_direct_value_rhs_unwrapped",
"lookup.tests.LookupTests.test_textfield_exact_null",
"many_to_many.tests.ManyToManyQueryTests.test_count_join_optimization_disabled",
"many_to_many.tests.ManyToManyQueryTests.test_exists_join_optimization_disabled",
"many_to_many.tests.ManyToManyTests.test_custom_default_manager_exists_count",
"queries.tests.ExistsSql.test_exists",
"queries.tests.Queries6Tests.test_col_alias_quoted",
},
Expand Down
2 changes: 2 additions & 0 deletions django_mongodb/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def process_lhs(node, compiler, connection):
# node is a Func or Expression, possibly with multiple source expressions.
result = []
for expr in node.get_source_expressions():
if expr is None:
continue
try:
result.append(expr.as_mql(compiler, connection))
except FullResultSet:
Expand Down

0 comments on commit 62b819e

Please sign in to comment.