Opened 8 years ago

Closed 8 years ago

#10181 closed (fixed)

Queryset raising EmptyResultSet exception (instead of being empty)

Reported by: omat Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: EmptyResultSet, ValuesListQuerySet
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

EmptyResultSet exception is fired in 'in' lookups, if the lookup is against an empty ValuesListQuerySet.

>>> ids = Tag.objects.filter(id__in=[]).values_list(id, flat=True)
>>> Tag.objects.filter(id__in=ids)

ids is an empty ValuesListQuerySet, as expected. The second line raises EmptyResultSet exception, where I would expect an empty QuerySet instead.

Change History (3)

comment:1 Changed 8 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Malcolm Tredinnick

Summary: EmptyResultSet exceptionQueryset raising EmptyResultSet exception (instead of being empty)

Fixed title to be something descriptive.

comment:3 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [9951]) Fixed #10181 -- Handle an EmptyResultSet exception case properly in nested querysets.

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