#30246: Using an annotated field calculated with 
django.db.models.functions.Extract
in aggregate results in ProgrammingError
-------------------------------------+-------------------------------------
     Reporter:  Jan BaryƂa           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  query, aggregate,    |             Triage Stage:  Accepted
  extract, annotate, postgresql      |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * cc: Simon Charette (added)
 * keywords:  query, aggregate, extract, annotate => query, aggregate,
     extract, annotate, postgresql
 * stage:  Unreviewed => Accepted


Comment:

 Thank you for the extra details and the tests, it looks like something is
 effectively broken with filtered aggregation over annotations when using
 the `FILTER (WHERE)` clause on PostgreSQL since it was introduced then.

 I happen to have been working in the area of code dealing with such
 queries recently to address issues with subqueries
 (`sql.Query.get_aggregation`/`rewrite_cols`) and reviewed the PR that
 added the `Aggregate(filter)` support so I'd be happy to help on getting
 this fixed. Could you give [https://github.com/django/django/pull/11062
 this PR] a try against your test and see if it happens to resolve the
 issue?

 Something that would also be useful knowing is the exact bogus query that
 the ORM generates.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30246#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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.e3f104da4b6e50c1deb1b43c497084a6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to