Skip to content

Commit f87e418

Browse files
committed
update to Django 5.1
1 parent 4eb75cd commit f87e418

File tree

13 files changed

+32
-145
lines changed

13 files changed

+32
-145
lines changed

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ python -m pip install -U pip
99
pip install -e .
1010

1111
# Install django and test dependencies
12-
git clone --branch mongodb-5.0.x https://github.com/mongodb-forks/django django_repo
12+
git clone --branch mongodb-5.1.x https://github.com/mongodb-forks/django django_repo
1313
pushd django_repo/tests/
1414
pip install -e ..
1515
pip install -r requirements/py3.txt

.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

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ explore and build. The best way to share this is via our [MongoDB Community Foru
77
## Install
88

99
Use the version of `django-mongodb-backend` that corresponds to your version of
10-
Django. For example, to get the latest compatible release for Django 5.0.x:
10+
Django. For example, to get the latest compatible release for Django 5.1.x:
1111
```bash
12-
$ pip install --pre django-mongodb-backend==5.0.*
12+
$ pip install --pre django-mongodb-backend==5.1.*
1313
```
1414
(Until the package is out of beta, you must use pip's `--pre` option.)
1515

@@ -21,11 +21,11 @@ $ pip install --pre django-mongodb-backend==5.0.*
2121
From your shell, run the following command to create a new Django project
2222
called `example` using our custom template. Make sure the zipfile referenced
2323
at the end of the template link corresponds to your
24-
version of Django. The snippet below specifies `5.0.x.zip` at the end of
25-
the template url to get the template for any Django version matching 5.0:
24+
version of Django. The snippet below specifies `5.1.x.zip` at the end of
25+
the template url to get the template for any Django version matching 5.1:
2626

2727
```bash
28-
$ django-admin startproject example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.0.x.zip
28+
$ django-admin startproject example --template https://github.com/mongodb-labs/django-mongodb-project/archive/refs/heads/5.1.x.zip
2929
```
3030

3131

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.0a3"
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
@@ -40,6 +40,12 @@ class DatabaseFeatures(BaseDatabaseFeatures):
4040
uses_savepoints = False
4141

4242
_django_test_expected_failures = {
43+
# $concat only supports strings, not int
44+
"db_functions.text.test_concat.ConcatTests.test_concat_non_str",
45+
# QuerySet.order_by() with annotation transform doesn't work:
46+
# "Expression $mod takes exactly 2 arguments. 1 were passed in"
47+
# https://github.com/django/django/commit/b0ad41198b3e333f57351e3fce5a1fb47f23f376
48+
"aggregation.tests.AggregateTestCase.test_order_by_aggregate_transform",
4349
# 'NulledTransform' object has no attribute 'as_mql'.
4450
"lookup.tests.LookupTests.test_exact_none_transform",
4551
# "Save with update_fields did not affect any rows."
@@ -70,6 +76,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
7076
# Connection creation doesn't follow the usual Django API.
7177
"backends.tests.ThreadTests.test_pass_connection_between_threads",
7278
"backends.tests.ThreadTests.test_default_connection_thread_local",
79+
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_thread_database_connection",
7380
# Object of type ObjectId is not JSON serializable.
7481
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
7582
# GenericRelation.value_to_string() assumes integer pk.
@@ -164,6 +171,7 @@ def django_test_expected_failures(self):
164171
"fixtures.tests.FixtureLoadingTests.test_loading_and_dumping",
165172
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_proxied",
166173
"m2m_through_regress.test_multitable.MultiTableTests.test_m2m_prefetch_reverse_proxied",
174+
"many_to_many.tests.ManyToManyQueryTests.test_prefetch_related_no_queries_optimization_disabled",
167175
"many_to_many.tests.ManyToManyTests.test_add_after_prefetch",
168176
"many_to_many.tests.ManyToManyTests.test_add_then_remove_after_prefetch",
169177
"many_to_many.tests.ManyToManyTests.test_clear_after_prefetch",
@@ -375,7 +383,11 @@ def django_test_expected_failures(self):
375383
"delete.tests.DeletionTests.test_only_referenced_fields_selected",
376384
"expressions.tests.ExistsTests.test_optimizations",
377385
"lookup.tests.LookupTests.test_in_ignore_none",
386+
"lookup.tests.LookupTests.test_lookup_direct_value_rhs_unwrapped",
378387
"lookup.tests.LookupTests.test_textfield_exact_null",
388+
"many_to_many.tests.ManyToManyQueryTests.test_count_join_optimization_disabled",
389+
"many_to_many.tests.ManyToManyQueryTests.test_exists_join_optimization_disabled",
390+
"many_to_many.tests.ManyToManyTests.test_custom_default_manager_exists_count",
379391
"migrations.test_commands.MigrateTests.test_migrate_syncdb_app_label",
380392
"migrations.test_commands.MigrateTests.test_migrate_syncdb_deferred_sql_executed_with_schemaeditor",
381393
"queries.tests.ExistsSql.test_exists",
@@ -423,6 +435,7 @@ def django_test_expected_failures(self):
423435
"raw_query.tests.RawQueryTests",
424436
"schema.test_logging.SchemaLoggerTests.test_extra_args",
425437
"schema.tests.SchemaTests.test_remove_constraints_capital_letters",
438+
"test_utils.tests.AllowedDatabaseQueriesTests.test_allowed_database_copy_queries",
426439
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_accepts_naive_datetime",
427440
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_returns_naive_datetime",
428441
"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 & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def create_model(self, model):
5151

5252
def _create_model_indexes(self, model, column_prefix="", parent_model=None):
5353
"""
54-
Create all indexes (field indexes & uniques, Meta.index_together,
55-
Meta.unique_together, Meta.constraints, Meta.indexes) for the model.
54+
Create all indexes (field indexes & uniques, Meta.unique_together,
55+
Meta.constraints, Meta.indexes) for the model.
5656
5757
If this is a recursive call due to an embedded model, `column_prefix`
5858
tracks the path that must be prepended to the index's column, and
@@ -71,11 +71,6 @@ def _create_model_indexes(self, model, column_prefix="", parent_model=None):
7171
self._add_field_index(parent_model or model, field, column_prefix=column_prefix)
7272
elif self._field_should_have_unique(field):
7373
self._add_field_unique(parent_model or model, field, column_prefix=column_prefix)
74-
# Meta.index_together (RemovedInDjango51Warning)
75-
for field_names in model._meta.index_together:
76-
self._add_composed_index(
77-
model, field_names, column_prefix=column_prefix, parent_model=parent_model
78-
)
7974
# Meta.unique_together
8075
if model._meta.unique_together:
8176
self.alter_unique_together(
@@ -208,15 +203,6 @@ def _remove_model_indexes(self, model, column_prefix="", parent_model=None):
208203
self._remove_field_index(parent_model or model, field, column_prefix=column_prefix)
209204
elif self._field_should_have_unique(field):
210205
self._remove_field_unique(parent_model or model, field, column_prefix=column_prefix)
211-
# Meta.index_together (RemovedInDjango51Warning)
212-
for field_names in model._meta.index_together:
213-
self._remove_composed_index(
214-
model,
215-
field_names,
216-
{"index": True, "unique": False},
217-
column_prefix=column_prefix,
218-
parent_model=parent_model,
219-
)
220206
# Meta.unique_together
221207
if model._meta.unique_together:
222208
self.alter_unique_together(

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
intersphinx_mapping = {
4040
"django": (
41-
"https://docs.djangoproject.com/en/5.0/",
42-
"http://docs.djangoproject.com/en/5.0/_objects/",
41+
"https://docs.djangoproject.com/en/5.1/",
42+
"http://docs.djangoproject.com/en/5.1/_objects/",
4343
),
4444
"pymongo": ("https://pymongo.readthedocs.io/en/stable/", None),
4545
"python": ("https://docs.python.org/3/", None),

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
django-mongodb-backend 5.0.x documentation
1+
django-mongodb-backend 5.1.x documentation
22
==========================================
33

44
.. toctree::

0 commit comments

Comments
 (0)