Opened 14 years ago
Closed 14 years ago
#14622 closed (fixed)
ValuesListQuerySet used with a foo__in filter breaks in SQL generation
Reported by: | Calvin Spealman | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
A similar bug was reported in #10181 but I do not believe it was entirely fixed. The testcase added by changeset [9951] only tests
>>> Tag.objects.filter(id__in=Tag.objects.filter(id__in=[]))
However, this is using an explicit empty list and not an empty ValuesListQuerySet. Something like
>>> Tag.objects.filter(id__in=Tag.objects.filter(id__in=Tag.objects.none().values_list('id', flat=True)))
will fail in SQL generation, because an empty ValuesListQuerySet() seems to be missing several key attributes. This seems to be because ValuesQuerySet._clone() method is called with setup=False and it never establishes the attributes expected.
Change History (3)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed by a previous commit, I added a test explicitly about values_list() though.
(In [14568]) Added a test for using an
__in
lookup with a ValueListQueryset from a none() call. Refs #14622.