-
Notifications
You must be signed in to change notification settings - Fork 301
Allow defining of select_related
per include
#600
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. See my inline comments. And I assume once we have settled on the implementation you will follow up on the other PR TODOs.
Codecov Report
@@ Coverage Diff @@
## master #600 +/- ##
==========================================
- Coverage 95.66% 95.39% -0.28%
==========================================
Files 56 56
Lines 2861 2865 +4
==========================================
- Hits 2737 2733 -4
- Misses 124 132 +8
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #600 +/- ##
==========================================
+ Coverage 96.16% 96.16% +<.01%
==========================================
Files 56 56
Lines 2866 2870 +4
==========================================
+ Hits 2756 2760 +4
Misses 110 110
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is shaping up nicely. I like the auto select_related part.
See my inline comments for some last changes and questions.
83215a4
to
0d126bc
Compare
select_related
per include
Fixes #591
Description of the Change
This PR adds
SelectAndPrefetchForIncludesMixin
which handlesinclude
GET parameter and addsselect_related
and/orprefetch_related
calls to queryset in order to save some sql queries.This also deprecates
PrefetchForIncludesHelperMixin
.AutoPrefetchMixin
is modified so if developer declaredprefetch_for_includes
that means that it's handled "manually" and no need to auto prefetch related entities.Let's say we have a code like below:
Line
'product': 'product__tags'
will save one query per included product, because it will prefetch tags.Checklist
CHANGELOG.md
updated (only for user relevant changes)AUTHORS