#34024: 'WhereNode' object has no attribute 'is_summary' when counting a
queryset
with annotation from a subquery
-------------------------------------+-------------------------------------
Reporter: vrigal | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I reproduced on a blank project (4.0 and 4.1 with a Postgres database)
using this use case:
`models.py`
{{{
class School(models.Model):
"""A school"""
class Director(models.Model):
school = models.ForeignKey(School, on_delete=models.CASCADE)
speciality = models.CharField(max_length=200)
}}}
It is not possible to run this code:
{{{#!python
>>> School.objects.annotate(
>>> speciality=Subquery(Director.objects.values('speciality')[:1]),
>>> has_speciality=Q(speciality__isnull=False)
>>> ).count()
…
AttributeError: 'WhereNode' object has no attribute 'is_summary'
}}}
Reverting this precise commit seems to fix the issue :
https://github.com/django/django/commit/b64db05b9cedd96905d637a2d824cbbf428e40e7
The request is a bit exotic, I don't know if it should be supported.
This is the first ticket I open, I can clarify/submit a merge request if
needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/34024>
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/010701835b183b4a-55204fff-5224-4008-b833-d9aad436f4b6-000000%40eu-central-1.amazonses.com.