#34024: 'WhereNode' object has no attribute 'is_summary' when counting a 
queryset
with annotation from a subquery
-------------------------------------+-------------------------------------
     Reporter:  Valentin Rigal       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               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 David Sanders):

 Here's a simple boiled down failing test case:

 {{{
 diff --git a/tests/queries/tests.py b/tests/queries/tests.py
 index 1bd72dd8b8..c6d9b05761 100644
 --- a/tests/queries/tests.py
 +++ b/tests/queries/tests.py
 @@ -1312,6 +1312,10 @@ class Queries1Tests(TestCase):
          )
          self.assertSequenceEqual(Note.objects.exclude(negate=True),
 [self.n3])

 +    def test_count_on_annotation(self):
 +        # Ticket: #34024
 +        Tag.objects.annotate(has_pk=~Q(pk=None)).count()
 +

  class Queries2Tests(TestCase):
      @classmethod
 }}}

 results

 {{{
 E
 ======================================================================
 ERROR: test_count_on_annotation (queries.tests.Queries1Tests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/Users/davids/projects/django/tests/queries/tests.py", line 1317,
 in test_count_on_annotation
     Tag.objects.annotate(has_pk=~Q(pk=None)).count()
   File "/Users/davids/projects/django/django/db/models/query.py", line
 621, in count
     return self.query.get_count(using=self.db)
   File "/Users/davids/projects/django/django/db/models/sql/query.py", line
 554, in get_count
     return obj.get_aggregation(using, ["__count"])["__count"]
   File "/Users/davids/projects/django/django/db/models/sql/query.py", line
 503, in get_aggregation
     if expression.is_summary:
 AttributeError: 'WhereNode' object has no attribute 'is_summary'

 ----------------------------------------------------------------------
 Ran 1 test in 0.014s

 FAILED (errors=1)
 Destroying test database for alias 'default'...
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34024#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/010701835fa5c2e8-f2f86569-2def-44f3-a19b-fc21a3052fe6-000000%40eu-central-1.amazonses.com.

Reply via email to