Skip to content

Conversation

timgraham
Copy link
Member

au objects are authors, not articles. Failure observed on MongoDB after d3cf24e which removed the skipping of this test.

@github-actions github-actions bot added the no ticket Based on PR title, no linked Trac ticket label Aug 27, 2025
@jacobtylerwalls jacobtylerwalls self-requested a review August 27, 2025 14:51
Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Thanks! Did a quick sanity check that after this update the test still fails if the code regresses.

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Aug 27, 2025

@timgraham I noticed there's a similar au/a confusion in test_in_bulk_non_unique_field, although it doesn't amount to much since it's an error condition. Does it make sense to fix in this PR?

@timgraham
Copy link
Member Author

I changed it at first before realizing that test uses field_name="author".

@jacobtylerwalls
Copy link
Member

But I think it's still supposed be an Article instance, which is a model with an author field (that is not distinct).

@timgraham timgraham force-pushed the test_in_bulk_preserve_ordering branch from e32dcce to 22aaf18 Compare August 27, 2025 18:56
@timgraham timgraham force-pushed the test_in_bulk_preserve_ordering branch from 22aaf18 to 49ea5d5 Compare August 27, 2025 19:04
@timgraham
Copy link
Member Author

When you specify field_name, the id_list (first argument of in_bulk()) is a list of the values of the field, e.g. Blog.objects.in_bulk(["beatles_blog"], field_name="slug"). So if we're querying author, then id_list must contain authors (or author ids).

@jacobtylerwalls
Copy link
Member

Yep, but we're querying Article, no?

@timgraham
Copy link
Member Author

We have field_name="author" so we're querying articles by authors.

Article.objects.in_bulk([self.au1], field_name="author")

Or it could be written ([self.a1.author])

Article.objects.in_bulk([self.a1], field_name="author") would match an article id to author ids.

(One and two letter variable names don't help!!)

@jacobtylerwalls jacobtylerwalls merged commit 1285de5 into django:main Aug 27, 2025
32 checks passed
@jacobtylerwalls
Copy link
Member

Thanks for the catch and the patient explanations! 🎯

@timgraham timgraham deleted the test_in_bulk_preserve_ordering branch August 28, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no ticket Based on PR title, no linked Trac ticket
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants