#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 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
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34975#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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018bde7cf397-96dc58b4-79f8-4866-8187-88aa874816d4-000000%40eu-central-1.amazonses.com.

Reply via email to