#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 felixxm):
* cc: Simon Charette (added) Comment: I would expect that the first kwarg (e.g. `age_alias=Sum(F('age')`) overrides the previous annotation (e.g. `age_alias=F('age')`) and a `FieldError` ''"Cannot compute Avg('age_alias'): 'age_alias' is an aggregate"'' is raised, like with annotations: - `Author.objects.annotate(age_alias=F('age')).annotate(age_alias=Sum(F('age'))).annotate(avg_age=Avg(F('age_alias')))`, - `Author.objects.annotate(age_alias=F('age')).annotate(age_alias=Sum(F('age')), avg_age=Avg(F('age_alias')))`. IMO it's not obvious how such querysets should behave. I think we should raise an error if an `aggregate()` overrides and refs to the same alias. -- Ticket URL: <https://code.djangoproject.com/ticket/31880#comment:6> 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.feed9bc1ecc5efbb9b68d28d2f53ea43%40djangoproject.com.