Skip to content

add expression support to QuerySet.update() #112

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

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

WaVEV
Copy link
Collaborator

@WaVEV WaVEV commented Aug 21, 2024

Fixes #102

@WaVEV WaVEV requested a review from timgraham August 21, 2024 18:27
@WaVEV WaVEV marked this pull request as ready for review August 21, 2024 21:06
@@ -342,12 +293,6 @@ def django_test_expected_failures(self):
"delete_regress.tests.Ticket19102Tests.test_ticket_19102_select_related",
"one_to_one.tests.OneToOneTests.test_o2o_primary_key_delete",
},
"Cannot use QuerySet.update() when querying across multiple collections on MongoDB.": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we should keep this error message. Raising "Using a QuerySet in annotate() is not supported on MongoDB" isn't helpful for the user since this isn't what they're doing but rather what Django is doing behind the scenes (kind of... really this error message needs to be changed since Query is used in more than just annotate()).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok. yes, But the other test are going to be recategorized also?

spec.setdefault("$set", {})[field.column] = value
return self.execute_update(spec)

@wrap_database_errors
Copy link
Collaborator

Choose a reason for hiding this comment

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

We lost this decorator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Who needs the safe net?! my bad. 😬 deleted by mistake.

@WaVEV WaVEV force-pushed the support-update-with-expression branch from 39e15fd to a8ff458 Compare August 22, 2024 01:17
@timgraham timgraham changed the title Support update with expression add expression support to QuerySet.update() Aug 22, 2024
@WaVEV WaVEV force-pushed the support-update-with-expression branch from 6abb648 to c6d4736 Compare August 22, 2024 03:35
@timgraham timgraham force-pushed the support-update-with-expression branch from c6d4736 to 2d96786 Compare August 22, 2024 22:02
@timgraham timgraham merged commit 2d96786 into mongodb:main Aug 22, 2024
3 checks passed
@WaVEV WaVEV deleted the support-update-with-expression branch August 23, 2024 02:38
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.

PYTHON-4676: add support for QuerySet.update() with expression
2 participants