Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to Django 5.1 #82

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion django_mongodb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _prepare_expressions_for_pipeline(self, expression, target, annotation_group
rhs = sub_expr.as_mql(self, self.connection, resolve_inner_expression=True)
group[alias] = {"$addToSet": rhs}
replacing_expr = sub_expr.copy()
replacing_expr.set_source_expressions([inner_column])
replacing_expr.set_source_expressions([inner_column, None])
else:
group[alias] = sub_expr.as_mql(self, self.connection)
replacing_expr = inner_column
Expand Down
13 changes: 13 additions & 0 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 @@ -78,6 +84,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
# Connection creation doesn't follow the usual Django API.
"backends.tests.ThreadTests.test_pass_connection_between_threads",
"backends.tests.ThreadTests.test_default_connection_thread_local",
"test_utils.tests.DisallowedDatabaseQueriesTests.test_disallowed_thread_database_connection",
# Object of type ObjectId is not JSON serializable.
"auth_tests.test_views.LoginTest.test_login_session_without_hash_session_key",
# GenericRelation.value_to_string() assumes integer pk.
Expand Down Expand Up @@ -170,6 +177,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 @@ -381,7 +389,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 Expand Up @@ -429,6 +441,7 @@ def django_test_expected_failures(self):
"raw_query.tests.RawQueryTests",
"schema.test_logging.SchemaLoggerTests.test_extra_args",
"schema.tests.SchemaTests.test_remove_constraints_capital_letters",
"test_utils.tests.AllowedDatabaseQueriesTests.test_allowed_database_copy_queries",
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_accepts_naive_datetime",
"timezones.tests.LegacyDatabaseTests.test_cursor_execute_returns_naive_datetime",
"timezones.tests.LegacyDatabaseTests.test_raw_sql",
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
7 changes: 2 additions & 5 deletions django_mongodb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def create_model(self, model):

def _create_model_indexes(self, model):
"""
Create all indexes (field indexes & uniques, Meta.index_together,
Meta.unique_together, Meta.constraints, Meta.indexes) for the model.
Create all indexes (field indexes & uniques, Meta.unique_together,
Meta.constraints, Meta.indexes) for the model.
"""
if not model._meta.managed or model._meta.proxy or model._meta.swapped:
return
Expand All @@ -42,9 +42,6 @@ def _create_model_indexes(self, model):
self._add_field_index(model, field)
elif self._field_should_have_unique(field):
self._add_field_unique(model, field)
# Meta.index_together (RemovedInDjango51Warning)
for field_names in model._meta.index_together:
self._add_composed_index(model, field_names)
# Meta.unique_together
if model._meta.unique_together:
self.alter_unique_together(model, [], model._meta.unique_together)
Expand Down
Loading