Opened 5 years ago

Closed 5 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 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by adamnelson

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #12687

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