Skip to content

Conversation

@konchunas
Copy link

Description

This PR fixes a bug with prefetch_related not actually being prefetched for entries with fk_id==0.
It happened because getattr returned 0 which is interpreted as False for if condition check.

Motivation and Context

I have a table where foreign key id = 0 is a valid value.
Somehow prefetch_related always sets fk_id to None and fk to NoneAwaitable for such records.

How Has This Been Tested?

My project runs on Postgres and It works well. It doesn't break anything else.
I've made a simplest test for this case.
The change doesn't affect other tests, but I only ran make test

Checklist:

  • My code follows the code style of this project. (NOT SURE)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Co-authored-by: Andrey Shpak <insspb@users.noreply.github.com>
long2ice
long2ice previously approved these changes Jul 1, 2022
CHANGELOG.rst Outdated

0.18
====
0.18.3
Copy link
Member

Choose a reason for hiding this comment

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

Please add in 0.19.2

Copy link
Author

Choose a reason for hiding this comment

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

Done, thank you

@abondar
Copy link
Member

abondar commented Jun 2, 2024

@konchunas Hi!

Sorry this PR got forgotten

Could you please rebase on fresh develop and move it to new changelog section (0.21.4)?

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.

4 participants