Code

Opened 4 years ago

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

Attachments (0)

Change History (3)

comment:1 Changed 4 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 4 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 4 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.

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.