Skip to content

Fixes #489: PKOnlyObject object has no attribute for retrieve_related of a to-one relationship #513

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

Closed
wants to merge 2 commits into from

Conversation

n2ygk
Copy link
Contributor

@n2ygk n2ygk commented Nov 12, 2018

Fixes #489

Description of the Change

Fixes incorrect PKOnly optimization for a toOne relationship by overriding use_pk_only_optimization in RelatedMixin.get_related_instance.

This behavior is selectable by overriding the RelatedMixin.override_pk_only_optimization feature flag which is used to demonstrate the bug in the test case code. After some time with no issues identified, we should consider removing this feature flag.

See #492 for further discussion.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated (via docstrings)
  • changelog entry added to CHANGELOG.md
  • author name in AUTHORS

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…`retrieve_related` of a to-one relationship
@n2ygk n2ygk requested a review from sliverc November 12, 2018 20:10
@sliverc
Copy link
Member

sliverc commented Nov 16, 2018

I have taken some time to read into this issue.

Monkey patching is always risky as it might cause side effects. I have written a bit of a different patch at #517 which fixes the issue without monkey patching and also uses the existing tests environment to reproduce the issue.

Best have a look there. Closing this PR in favor of #517

@sliverc sliverc closed this Nov 16, 2018
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.

None yet

2 participants