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 Dec 14, 2024
1 parent 546554a commit b68dc95
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 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.0.x'
ref: 'mongodb-5.1.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.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,5 +1,5 @@
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 .query_utils import process_lhs
Expand All @@ -16,7 +16,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
13 changes: 11 additions & 2 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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",
# 'NulledTransform' object has no attribute 'as_mql'.
"lookup.tests.LookupTests.test_exact_none_transform",
# "Save with update_fields did not affect any rows."
Expand Down Expand Up @@ -170,6 +176,7 @@ def django_test_expected_failures(self):
"fixtures.tests.FixtureLoadingTests.test_loading_and_dumping",
"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 @@ -227,8 +234,6 @@ def django_test_expected_failures(self):
"expressions.tests.BasicExpressionsTests.test_nested_subquery_outer_ref_with_autofield",
"model_fields.test_foreignkey.ForeignKeyTests.test_to_python",
"queries.test_qs_combinators.QuerySetSetOperationTests.test_order_raises_on_non_selected_column",
"queries.tests.RelatedLookupTypeTests.test_values_queryset_lookup",
"queries.tests.ValuesSubqueryTests.test_values_in_subquery",
},
"Cannot use QuerySet.delete() when querying across multiple collections on MongoDB.": {
"admin_changelist.tests.ChangeListTests.test_distinct_for_many_to_many_at_second_level_in_search_fields",
Expand Down Expand Up @@ -381,7 +386,11 @@ def django_test_expected_failures(self):
"delete.tests.DeletionTests.test_only_referenced_fields_selected",
"expressions.tests.ExistsTests.test_optimizations",
"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",
"migrations.test_commands.MigrateTests.test_migrate_syncdb_app_label",
"migrations.test_commands.MigrateTests.test_migrate_syncdb_deferred_sql_executed_with_schemaeditor",
"queries.tests.ExistsSql.test_exists",
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 b68dc95

Please sign in to comment.