#17485: Queries with both deferred fields and select_related defer field.name
instead of field.attname
-------------------------------------+-------------------------------------
Reporter: koniiiik | Owner: koniiiik
Type: Bug | Status: new
Component: Database layer | Version: SVN
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: defer | Needs documentation: 0
select_related | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by koniiiik):
Okay, took me a little longer but I have an almost working solution to
this with the following behavior: an explicit `defer` combined with
`select_related` on the same field results in an `InvalidQuery`; deferring
a `ForeignKey` and using a depth-based `select_related` results in the
specific relationship being skipped.
Now the problem is, what should happen when someone uses `only` and
`select_related` in a way that the `ForeignKey` would be omitted? Do we
want to issue the exception as well or do we want to automatically add the
field to the set of loaded ones? Currently it behaves the first way,
though it might make sense in the second way as well.
It is used in
`regressiontests.select_related_regress.SelectRelatedRegressTests.test_regression_12851`
this way at the moment – should I go ahead and update the test or do we
want to keep the test case and add more magic?
Personally I'm in favor of the first behavior, i. e. raising an exception,
as it is more explicit. Stating I only want to load other fields and then
asking for a `select_related` on an omitted field seems contradictory to
me but there may be those who disagree.
--
Ticket URL: <https://code.djangoproject.com/ticket/17485#comment:5>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.