select_related() should work with ValuesQuerySets
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
(Some of you may be reading this for the second or third time since I brought it up both on the django-developers list and IRC)
There appears to be no way to make a query like this through the django models without using SQL or hitting the database twice:
SELECT trackback.title, blog.name, blog.url FROM trackback INNER JOIN blog ON trackback.blog_id = blog.id
As far as I know, selecting with table fields is preferred above using a SELECT * any time possible.
I understand this would break the model object to table row mapping of the QuerySet (objects woulnd't be complete if some fields
were missing), perhaps a new kind of QuerySet or ValueQuerySet is needed?
If this is something that would be a welcome addition to the codebase, I could probably help out.
Change History (8)
comment:1 Changed 10 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Design decision needed|
comment:4 follow-up: 6 Changed 10 years ago by
|Summary:||select_related() and selecting by db table fields → select_related() should work with ValueQuerySets|
comment:5 Changed 10 years ago by
|Summary:||select_related() should work with ValueQuerySets → select_related() should work with ValuesQuerySets|
comment:7 Changed 9 years ago by
|Triage Stage:||Design decision needed → Accepted|