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

Fixed #35690 -- Raise TypeError if QuerySet.in_bulk is called after QuerySet.values or QuerySet.values_list. #18496

Merged

Conversation

john-parton
Copy link
Contributor

@john-parton john-parton commented Aug 19, 2024

Trac ticket number

35690

Branch description

When calling QuerySet.values() followed by QuerySet.in_bulk(), an AttributeError is raised, which doesn't directly give the user feedback on how to resolve the error or what the user even did wrong. This adds an additional check and raises a TypeError with the appropriate message.

I can try and define the behavior, but I wanted to submit the simpler pull request for review before working on a more complicated fix.

Let me know if docs are required. A simple short note on the in_bulk method might be sufficient.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

tests/lookup/tests.py Outdated Show resolved Hide resolved
@john-parton
Copy link
Contributor Author

Just pushed a change replacing isinstance with issubclass. I'm not sure how my test passed before. Might be indicative of some hole in my test.

@john-parton john-parton force-pushed the bugfix/35690-in-bulk-after-values branch from 26785dc to 36f0838 Compare August 19, 2024 16:08
@john-parton
Copy link
Contributor Author

Force-pushed changes to test to make them more complete.

@sarahboyce sarahboyce force-pushed the bugfix/35690-in-bulk-after-values branch from 36f0838 to 6fc9da5 Compare September 2, 2024 12:15
@sarahboyce sarahboyce force-pushed the bugfix/35690-in-bulk-after-values branch from 6fc9da5 to 59f42e9 Compare September 2, 2024 12:22
Copy link
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

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

Thank you @john-parton 👍 this looks good to me

@sarahboyce sarahboyce merged commit e4a2e22 into django:main Sep 2, 2024
34 checks passed
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