#27719: Add queryset.alias() to mimic .annotate() for aggregations without 
loading
data
-------------------------------------+-------------------------------------
     Reporter:  Marc Tamlyn          |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     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 Marc Tamlyn):

 Whilst support in all the places which can use an annotated name would
 solve this kind of performance problem, there are loads of ways you can
 use a field name after it's defined.

 `.filter(name__lookup=value)`
 `.order_by('name')`
 `.annotate(SomeOtherExpression('name'))`
 `.values('name')` (and related APIs)`
 `.distinct()`
 `.date()` (and `datetimes`)
 `.defer('name')` (and `only`)

 I know that some of these places already support expressions. For very
 complex expressions there's utility in being able to "name" the expression
 as some kind of virtual field. If you're within the same function then a
 python reference is usually sufficient (except for the `__lookup` case),
 but if you have for example a manager method which would annotate a
 certain field and you use it elsewhere then things get messy quickly.

--
Ticket URL: <https://code.djangoproject.com/ticket/27719#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/066.1975361492470a897ad34ccb5527b95f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to