Skip to content

Commit 52af559

Browse files
committed
update to Django 5.1
1 parent c90a00c commit 52af559

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/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.0a0"
1+
__version__ = "5.1a0"
22

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

django_mongodb/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/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."
@@ -78,6 +84,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
7884
# Connection creation doesn't follow the usual Django API.
7985
"backends.tests.ThreadTests.test_pass_connection_between_threads",
8086
"backends.tests.ThreadTests.test_default_connection_thread_local",
87+
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_thread_database_connection",
8188
# Object of type ObjectId is not JSON serializable.
8289
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
8390
# GenericRelation.value_to_string() assumes integer pk.
@@ -170,6 +177,7 @@ def django_test_expected_failures(self):
170177
"fixtures.tests.FixtureLoadingTests.test_loading_and_dumping",
171178
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_proxied",
172179
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_reverse_proxied",
180+
"many_to_many.tests.ManyToManyQueryTests.test_prefetch_related_no_queries_optimization_disabled",
173181
"many_to_many.tests.ManyToManyTests.test_add_after_prefetch",
174182
"many_to_many.tests.ManyToManyTests.test_add_then_remove_after_prefetch",
175183
"many_to_many.tests.ManyToManyTests.test_clear_after_prefetch",
@@ -381,7 +389,11 @@ def django_test_expected_failures(self):
381389
"delete.tests.DeletionTests.test_only_referenced_fields_selected",
382390
"expressions.tests.ExistsTests.test_optimizations",
383391
"lookup.tests.LookupTests.test_in_ignore_none",
392+
"lookup.tests.LookupTests.test_lookup_direct_value_rhs_unwrapped",
384393
"lookup.tests.LookupTests.test_textfield_exact_null",
394+
"many_to_many.tests.ManyToManyQueryTests.test_count_join_optimization_disabled",
395+
"many_to_many.tests.ManyToManyQueryTests.test_exists_join_optimization_disabled",
396+
"many_to_many.tests.ManyToManyTests.test_custom_default_manager_exists_count",
385397
"migrations.test_commands.MigrateTests.test_migrate_syncdb_app_label",
386398
"migrations.test_commands.MigrateTests.test_migrate_syncdb_deferred_sql_executed_with_schemaeditor",
387399
"queries.tests.ExistsSql.test_exists",
@@ -429,6 +441,7 @@ def django_test_expected_failures(self):
429441
"raw_query.tests.RawQueryTests",
430442
"schema.test_logging.SchemaLoggerTests.test_extra_args",
431443
"schema.tests.SchemaTests.test_remove_constraints_capital_letters",
444+
"test_utils.tests.AllowedDatabaseQueriesTests.test_allowed_database_copy_queries",
432445
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_accepts_naive_datetime",
433446
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_returns_naive_datetime",
434447
"timezones.tests.LegacyDatabaseTests.test_raw_sql",

django_mongodb/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/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)