#34975: Getting refs does not work properly with models.Window and aggregation
-------------------------------------+-------------------------------------
     Reporter:  Sergey Nesterenko    |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  QuerySet, Window,    |             Triage Stage:  Accepted
  Aggregate, F                       |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Sergey Nesterenko):

 Replying to [comment:4 Simon Charette]:
 > I'm not sure if something else will break as I don't think we have
 extensive testing for performing filtered aggregation over a window
 function but does the following patch helps
 >
 > {{{#!python
 > diff --git a/django/db/models/expressions.py
 b/django/db/models/expressions.py
 > index 3a0c75ebf2..74ae9cab8e 100644
 > --- a/django/db/models/expressions.py
 > +++ b/django/db/models/expressions.py
 > @@ -417,6 +417,8 @@ def replace_expressions(self, replacements):
 >      def get_refs(self):
 >          refs = set()
 >          for expr in self.get_source_expressions():
 > +            if expr is None:
 > +                continue
 >              refs |= expr.get_refs()
 >          return refs
 > }}}


 I thought about it, but I wasn't sure it wouldn't break anything, but it
 might work.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34975#comment:5>
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/0107018bde8126dd-fdadeef2-d87d-4fd6-88d4-9708f86d8399-000000%40eu-central-1.amazonses.com.

Reply via email to