#34016: QuerySet.values_list() crash on simple ArrayAgg.
----------------------------------+------------------------------------
     Reporter:  Alex Kerkum       |                    Owner:  (none)
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  4.1
     Severity:  Release blocker   |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

 We could skip an empty `OrderByList` 🤔:
 {{{#!diff
 diff --git a/django/contrib/postgres/aggregates/mixins.py
 b/django/contrib/postgres/aggregates/mixins.py
 index b2f4097b8f..2bf236474a 100644
 --- a/django/contrib/postgres/aggregates/mixins.py
 +++ b/django/contrib/postgres/aggregates/mixins.py
 @@ -14,10 +14,13 @@ class OrderableAggMixin:
          return super().resolve_expression(*args, **kwargs)

      def get_source_expressions(self):
 +        if not self.order_by.source_expressions:
 +            return super().get_source_expressions()
          return super().get_source_expressions() + [self.order_by]

      def set_source_expressions(self, exprs):
 -        *exprs, self.order_by = exprs
 +        if isinstance(exprs[-1], OrderByList):
 +            *exprs, self.order_by = exprs
          return super().set_source_expressions(exprs)

      def as_sql(self, compiler, connection):

 }}}

 Alex, would you like to prepare a patch? (regression test is required)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34016#comment:4>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018345ad2168-294a81d7-54d5-4e8c-9ee8-e4b656ef4b17-000000%40eu-central-1.amazonses.com.

Reply via email to