Opened 5 years ago

Closed 5 years ago

#14622 closed (fixed)

ValuesListQuerySet used with a foo__in filter breaks in SQL generation

Reported by: calvinspealman 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: UI/UX:

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 Changed 5 years ago by Alex

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

comment:2 Changed 5 years ago by Alex

(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 Changed 5 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

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