Opened 7 years ago

Closed 6 years ago

#13356 closed (duplicate)

EmptyResultSet when using annotation and empty filter

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Following code works :

from django.contrib.auth.models import User
from django.db.models import Count
User.objects.filter(id__in=[]).annotate(Count('groups'))
[]
User.objects.filter(id__in=[]).count()
0

But following code raise EmptyResultSet:

User.objects.filter(id__in=[]).annotate(Count('groups')).count()

(I don't know what is right - Error or empty response. But it is sure that current state is inconsistent.)

Change History (2)

comment:1 Changed 7 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Adam Nelson

Resolution: duplicate
Status: newclosed

Duplicate of #12687

Note: See TracTickets for help on using tickets.
Back to Top