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

Conversation

timgraham
Copy link
Collaborator

Django 5.1 will be released ~August 7, 2024.

This is to check compatibility in the meantime.

@timgraham timgraham marked this pull request as draft July 15, 2024 23:07
@timgraham timgraham force-pushed the django51 branch 3 times, most recently from c1920be to 98ee338 Compare July 19, 2024 15:18
@timgraham timgraham force-pushed the django51 branch 2 times, most recently from 55fd0c5 to ee44faf Compare July 26, 2024 00:37
@timgraham timgraham force-pushed the django51 branch 2 times, most recently from 8eca616 to d4176d2 Compare August 6, 2024 17:30
@timgraham timgraham force-pushed the django51 branch 3 times, most recently from 9ec98b9 to 6cd1c8b Compare August 22, 2024 23:21
@@ -19,7 +19,7 @@ def aggregate(
resolve_inner_expression=False,
**extra_context, # noqa: ARG001
):
if self.filter:
if self.filter and not isinstance(self.filter, Col):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WaVEV I'm not sure if this change is correct, but it fixes aggregation.tests.AggregateTestCase.test_distinct_on_aggregate which otherwise incorrectly go down this branch after django/django@42b567a. Incidentally, that's also the commit that requires the additional of the if expr is Nonecheck in query_utils.py.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 wow interesting, I will check

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit strange. Here’s what I noticed:

  1. In the mongodb-5.1.x branch, Django is generating some aggregation nodes like: Avg(, distinct=True, filter=Col(aggregation_book, <django.db.models.fields.FloatField: ratings>)). Meanwhile, version 5.1 using SQLite is generating the following node: Avg(Col(aggregation_book, aggregation.Book.rating), distinct=True). The first aggregation node with empty expressions and the proper column in the filter is unusual.

  2. We can handle cases where the filter has no expression but a column, though this might not be a common scenario. I’ll need to debug Django to understand why these versions generate different nodes. I believe it should always receive an expression, so this situation might be an edge case.

  3. In the mongodb-5.0.x branch, the node is the same as in Django 5.1, so I think an error may have been introduced in mongodb-5.1.x.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I think an error may have been introduced in mongodb-5.1.x.

Right. Did you study the Django commit I linked to? I think it's likely we should update our code in some way other than this isinstance check, but I haven't dug in to understand the details. (This isn't the highest priority right now, but if you have some free cycles...)

Copy link
Collaborator

@WaVEV WaVEV Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I found the problem, we need to adapt Django-mongodb. As you noticed the set_source_expressions has changed, so we have to change the line 94 from the file compiler with:
replacing_expr.set_source_expressions([inner_column, None]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants