Code

Opened 4 years ago

Closed 4 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.)

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by russellm

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

comment:2 Changed 4 years ago by adamnelson

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

Duplicate of #12687

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.