#31880: QuerySet.aggregate() mixes annotated fields names.
-------------------------------------+-------------------------------------
     Reporter:  Thodoris             |                    Owner:  David
  Sotiropoulos                       |  Wobrock
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by David Wobrock):

 * cc: David Wobrock (added)
 * owner:  nobody => David Wobrock
 * has_patch:  0 => 1
 * status:  new => assigned


Comment:

 Hi,

 I tried to tackle this ticket by fixing the actual bug.

 The [https://github.com/django/django/pull/13390 PR]

 It's surely not that an important bug and one could just use a different
 alias for the aggregation, but I wanted to get to the bottom.

 Aggregations are actually also registering annotations, meaning that the
 annotation alias is overridden, and the subquery is not aware of the field
 anymore.
 I thought of three ways to solve this:
 * raise an error when an aggregation is overriding the alias of an
 annotation (basically, forbid the buggy case) -- easy to implement, but I
 think it's a pity to forbid something that could work.
 * implement the smallest change that will allow this case -- it's the
 approach implemented in the linked patch.
 * handle differently aggregation annotations and simple annotations -- a
 large change, which would require quite a rewrite of parts of the
 aggregation logic and would be ''a lot'' of work for such a small edge
 case I guess.

 I hope it makes sense to you and I'm open to changing to any other and
 better approach :)
 David

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31880#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.53e3c81e19cd1959e61abcbeba1c9198%40djangoproject.com.

Reply via email to