Skip to content

Commit 4f247d5

Browse files
committed
update to Django 5.1
1 parent 419b97e commit 4f247d5

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
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.0.x'
36+
ref: 'mongodb-5.1.x'
3737
path: 'django_repo'
3838
persist-credentials: false
3939
- name: Install system packages for Django's Python test dependencies

django_mongodb_backend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.0.0a1"
1+
__version__ = "5.1.0a1"
22

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

django_mongodb_backend/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _prepare_expressions_for_pipeline(self, expression, target, annotation_group
9191
rhs = sub_expr.as_mql(self, self.connection, resolve_inner_expression=True)
9292
group[alias] = {"$addToSet": rhs}
9393
replacing_expr = sub_expr.copy()
94-
replacing_expr.set_source_expressions([inner_column])
94+
replacing_expr.set_source_expressions([inner_column, None])
9595
else:
9696
group[alias] = sub_expr.as_mql(self, self.connection)
9797
replacing_expr = inner_column

django_mongodb_backend/features.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class DatabaseFeatures(BaseDatabaseFeatures):
4646
uses_savepoints = False
4747

4848
_django_test_expected_failures = {
49+
# $concat only supports strings, not int
50+
"db_functions.text.test_concat.ConcatTests.test_concat_non_str",
51+
# QuerySet.order_by() with annotation transform doesn't work:
52+
# "Expression $mod takes exactly 2 arguments. 1 were passed in"
53+
# https://github.com/django/django/commit/b0ad41198b3e333f57351e3fce5a1fb47f23f376
54+
"aggregation.tests.AggregateTestCase.test_order_by_aggregate_transform",
4955
# 'NulledTransform' object has no attribute 'as_mql'.
5056
"lookup.tests.LookupTests.test_exact_none_transform",
5157
# "Save with update_fields did not affect any rows."
@@ -76,6 +82,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
7682
# Connection creation doesn't follow the usual Django API.
7783
"backends.tests.ThreadTests.test_pass_connection_between_threads",
7884
"backends.tests.ThreadTests.test_default_connection_thread_local",
85+
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_thread_database_connection",
7986
# Object of type ObjectId is not JSON serializable.
8087
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
8188
# GenericRelation.value_to_string() assumes integer pk.
@@ -175,6 +182,7 @@ def django_test_expected_failures(self):
175182
"fixtures.tests.FixtureLoadingTests.test_loading_and_dumping",
176183
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_proxied",
177184
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_reverse_proxied",
185+
"many_to_many.tests.ManyToManyQueryTests.test_prefetch_related_no_queries_optimization_disabled",
178186
"many_to_many.tests.ManyToManyTests.test_add_after_prefetch",
179187
"many_to_many.tests.ManyToManyTests.test_add_then_remove_after_prefetch",
180188
"many_to_many.tests.ManyToManyTests.test_clear_after_prefetch",
@@ -386,7 +394,11 @@ def django_test_expected_failures(self):
386394
"delete.tests.DeletionTests.test_only_referenced_fields_selected",
387395
"expressions.tests.ExistsTests.test_optimizations",
388396
"lookup.tests.LookupTests.test_in_ignore_none",
397+
"lookup.tests.LookupTests.test_lookup_direct_value_rhs_unwrapped",
389398
"lookup.tests.LookupTests.test_textfield_exact_null",
399+
"many_to_many.tests.ManyToManyQueryTests.test_count_join_optimization_disabled",
400+
"many_to_many.tests.ManyToManyQueryTests.test_exists_join_optimization_disabled",
401+
"many_to_many.tests.ManyToManyTests.test_custom_default_manager_exists_count",
390402
"migrations.test_commands.MigrateTests.test_migrate_syncdb_app_label",
391403
"migrations.test_commands.MigrateTests.test_migrate_syncdb_deferred_sql_executed_with_schemaeditor",
392404
"queries.tests.ExistsSql.test_exists",
@@ -434,6 +446,7 @@ def django_test_expected_failures(self):
434446
"raw_query.tests.RawQueryTests",
435447
"schema.test_logging.SchemaLoggerTests.test_extra_args",
436448
"schema.tests.SchemaTests.test_remove_constraints_capital_letters",
449+
"test_utils.tests.AllowedDatabaseQueriesTests.test_allowed_database_copy_queries",
437450
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_accepts_naive_datetime",
438451
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_returns_naive_datetime",
439452
"timezones.tests.LegacyDatabaseTests.test_raw_sql",

django_mongodb_backend/query_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def process_lhs(node, compiler, connection):
1212
# node is a Func or Expression, possibly with multiple source expressions.
1313
result = []
1414
for expr in node.get_source_expressions():
15+
if expr is None:
16+
continue
1517
try:
1618
result.append(expr.as_mql(compiler, connection))
1719
except FullResultSet:

django_mongodb_backend/schema.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def create_model(self, model):
3131

3232
def _create_model_indexes(self, model):
3333
"""
34-
Create all indexes (field indexes & uniques, Meta.index_together,
35-
Meta.unique_together, Meta.constraints, Meta.indexes) for the model.
34+
Create all indexes (field indexes & uniques, Meta.unique_together,
35+
Meta.constraints, Meta.indexes) for the model.
3636
"""
3737
if not model._meta.managed or model._meta.proxy or model._meta.swapped:
3838
return
@@ -42,9 +42,6 @@ def _create_model_indexes(self, model):
4242
self._add_field_index(model, field)
4343
elif self._field_should_have_unique(field):
4444
self._add_field_unique(model, field)
45-
# Meta.index_together (RemovedInDjango51Warning)
46-
for field_names in model._meta.index_together:
47-
self._add_composed_index(model, field_names)
4845
# Meta.unique_together
4946
if model._meta.unique_together:
5047
self.alter_unique_together(model, [], model._meta.unique_together)

0 commit comments

Comments
 (0)