#25871: Allow expressions in values() queryset method
-------------------------------------+-------------------------------------
Reporter: jarshwah | Owner: nobody
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords: expressions
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
It should be possible to insert expressions directly into a `values()`
method, rather than first annotating and then selecting in values().
{{{
# Proposed
Model.objects.values(complex=SomeExpression()).aggregate(Sum('field'))
# Current
Model.objects.annotate(complex=SomeExpression()).values('complex').aggregate(Sum('field'))
}}}
The major hurdle here is allowing `**kwargs` into `values()` to support
the alias. That's an addition to the API so should be backwards
compatible, but it'll also probably rule out using various state based
kwargs like `flat=True` and their ilk in the future. We could do some
juggling to ensure we're only processing expression kwargs as expressions
by checking if they have the attribute `resolve_expression`.
--
Ticket URL: <https://code.djangoproject.com/ticket/25871>
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/051.b412c146d38883af5981db7260212194%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.