Opened 14 years ago

Closed 13 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 Alex Gaynor, 13 years ago

(In [14568]) Added a test for using an __in lookup with a ValueListQueryset from a none() call. Refs #14622.

comment:2 by Alex Gaynor, 13 years ago

(In [14569]) [1.2.X] Added a test for using an __in lookup with a ValueListQueryset from a none() call. Refs #14622. Backport of [14568].

comment:3 by Alex Gaynor, 13 years ago

Resolution: fixed
Status: newclosed

This was fixed by a previous commit, I added a test explicitly about values_list() though.

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