Skip to content

Conversation

MaxDude132
Copy link
Contributor

Changed the cache name used for singly related objects to be the to_attr parameter passed to a Prefetch object. This fixes issues with checking if values have already been fetched in cases where the Field already has some prefetched value, but not for the same model attr.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello! Thank you for your contribution 💪

As it's your first contribution be sure to check out the patch review checklist.

If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!

If you have any design or process questions then you can ask in the Django forum.

Welcome aboard ⛵️!

@MaxDude132
Copy link
Contributor Author

@charettes There seems to be a test failing, but I don't think it has anything to do with the changes I made? Could it be a flaky (I don't know if you have many of those on django)?

@charettes
Copy link
Member

@MaxDude132 I confirm that it is flaky and not related to your changes.

@MaxDude132
Copy link
Contributor Author

@charettes I believe it is ready to merge

Copy link
Member

@charettes charettes left a comment

Choose a reason for hiding this comment

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

Looking great Maxime.

Left a few comments for tweaks it should eventually be reviewed. It might take a few days as we're currently approaching the feature freeze for 5.0 and fellows are busy merging changes before the window closes.

@MaxDude132
Copy link
Contributor Author

@charettes All changes were addressed. Thanks a lot for your help on this, it is much appreciated as this was my first real deep-dive into the Django code

@charettes
Copy link
Member

@MaxDude132 glad I could help, you did a good job at identifying the root cause and providing a patch.

… objects.

Changed the cache name used for singly related objects to be the
to_attr parameter passed to a Prefetch object. This fixes issues with
checking if values have already been fetched in cases where the Field
already has some prefetched value, but not for the same model attr.
@felixxm felixxm changed the title Fixed #34791 -- Fixed prefetch cache for singly related objects Fixed #34791 -- Fixed incorrect Prefetch()'s cache for singly related objects. Sep 7, 2023
@felixxm
Copy link
Member

felixxm commented Sep 7, 2023

@MaxDude132 Thanks 👍 Welcome aboard ⛵

@felixxm felixxm merged commit 254df3a into django:main Sep 7, 2023
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.

3 participants