#27535: RFE: Exclude pk from queries
-------------------------------------+-------------------------------------
Reporter: Alexander Todorov | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 1.10
(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 Marten Kenbeek):
`.values()` does a `GROUP BY`, so each record in the resulting queryset
can represent multiple rows in the original table. It doesn't make much
sense to represent these records as model instances: all model instance
methods assume that an instance represent a single row, and model
instances promise that all attributes are accessible. If a model instance
represents multiple rows, it's unclear what value deferred instance
attributes should have or what instance methods should do.
`.only()` is different because it does not remove information from the
instance, it simply defers retrieving that information from the database.
Each model instance still represent a single row in the database.
I'm -1 on this. If a method needs to support both kinds of querysets, it
should explicitly support both regular querysets and `.values()`
querysets. It's a tiny bit of extra code, but representing `.values()`
querysets with model instances would simply be incorrect.
--
Ticket URL: <https://code.djangoproject.com/ticket/27535#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 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/066.15accf5f6ee5f7797f4d641a329482f9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.