#34987: "Expression contains mixed types" exception when performing window 
function
on query that also has aggregates.
-------------------------------------+-------------------------------------
     Reporter:  ElRoberto538         |                    Owner:  Simon
                                     |  Charette
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:  fixed
     Keywords:  Expression, Window,  |             Triage Stage:  Accepted
  aggregate, annotation, partition   |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

 In [changeset:"95dec210e89a2fb46ffde2ba29ff7876e1d5f86e" 95dec21]:
 {{{
 #!CommitTicketReference repository=""
 revision="95dec210e89a2fb46ffde2ba29ff7876e1d5f86e"
 [5.0.x] Fixed #34987 -- Fixed queryset crash when mixing aggregate and
 window annotations.

 Regression in f387d024fc75569d2a4a338bfda76cc2f328f627.

 Just like `OrderByList` the `ExpressionList` expression used to wrap
 `Window.partition_by` must implement `get_group_by_cols` to ensure the
 necessary grouping when mixing window expressions with aggregate
 annotations is performed against the partition members and not the
 partition expression itself.

 This is necessary because while `partition_by` is implemented as
 a source expression of `Window` it's actually a fragment of the WINDOW
 expression at the SQL level and thus it should result in a group by its
 members and not the sum of them.

 Thanks ElRoberto538 for the report.
 Backport of e76cc93b0168fa3abbafb9af1ab4535814b751f0 from main
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34987#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/0107018bfa961851-2901d20e-ecca-4b43-ac75-dd9d2ee9e0ca-000000%40eu-central-1.amazonses.com.

Reply via email to