#33835: Select_related().only() in the Prefetch() should automatically add
primary
keys for reverse relations.
-------------------------------------+-------------------------------------
Reporter: Ipakeev | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
I agree with Mariusz's conclusion. If you're looking for a solution to
catch these problems early through in development on in your test suite
without peppering with it `assertNumQueries` I suggest you look into
[https://github.com/charettes/django-seal third-party solutions] that will
emit warnings when such problems occur.
In your particular case you would have gotten a warning along the lines of
`UnsealedAttributeAccess: Attempt to fetch deferred field "publisher_id"
on sealed <Book instance>`
Which can be elevated to an error during development or tests via
`warnings.filterwarnings('error', category=UnsealedAttributeAccess)`
This origin of this package was the exact same as yours; we needed a tool
to allow the efficient creation of Queryset for a GraphQL querying
endpoint and wanted to catch N+1 query problems due to missing
`select_related`, `prefetch_related` or too eager usage of field deferral.
--
Ticket URL: <https://code.djangoproject.com/ticket/33835#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070181ed70e651-c56eb714-b88e-4944-9e29-d1dcb25deca2-000000%40eu-central-1.amazonses.com.