#24048: only() doesn't override fields included in defer() as documented
-------------------------------------+-------------------------------------
Reporter: wearp | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: defer, only, | Triage Stage: Accepted
QuerySet, DeferredAttribute |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by wearp):
Replying to [comment:1 timgraham]:
> I checked back to 29050ef999e1931efb6c62471c7e07d2ea5e96ea where
`defer()` was added and this assertion in `tests/defer` (or its equivalent
in the original doc test) fails,
`self.assert_delayed(qs.defer("name").only("value", "name")[0], 1)` as
"name" is indeed deferred despite its inclusion in `only()`. It seems
expected to me that `only()` would override `defer()` so we should see
about making that change, but if we can't due to backwards compatibility
or implementation, we should definitely correct the docs.
Looking at the comment for `only()` it says,
`Only the fields passed into this method and that are not already
specified as deferred are loaded immediately when the queryset is
evaluated.`
This would mean that the method behaves as intended and the documentation
is incorrect. `add_immediate_loading()` (which is called by `only()`) also
behaves in the same way, not overriding deferred fields passed to it.
--
Ticket URL: <https://code.djangoproject.com/ticket/24048#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.771a2b8bb0e9dfabba43d70ee5dc94a7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.