Opened 10 years ago

Closed 10 years ago

#6772 closed (fixed)

`in` lookup type no longer works with tuples

Reported by: jbronn Owned by: Malcolm Tredinnick
Component: Database layer (models, ORM) Version: queryset-refactor
Severity: Keywords: qs-rf in lookup
Cc: jbronn Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by jbronn)

When using a tuple parameter, instead of a list, the in lookup type will raise an exception:

>>> MyModel.objects.filter(name__in=['Foo', 'Bar'])
[<MyModel: Foo>, <MyModel: Bar>]
>>> MyModel.objects.filter(name__in=('Foo', 'Bar'))
Traceback (most recent call last):
  File "/Users/jbronn/django/queryset-refactor/django/db/models/", line 28, in __repr__
    return repr(list(iter(self)))
  File "/Users/jbronn/django/queryset-refactor/django/db/models/", line 46, in __iter__
  File "/Users/jbronn/django/queryset-refactor/django/db/models/", line 446, in _fill_cache
  File "/Users/jbronn/django/queryset-refactor/django/db/models/", line 127, in iterator
    for row in self.query.results_iter():
  File "/Users/jbronn/django/queryset-refactor/django/db/models/sql/", line 163, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/Users/jbronn/django/queryset-refactor/django/db/models/sql/", line 1301, in execute_sql
    cursor.execute(sql, params)
  File "/Users/jbronn/django/queryset-refactor/django/db/backends/", line 18, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: syntax error at or near "Foo"
LINE 1: ...."name" FROM "tmp_mymodel" WHERE "tmp_mymodel"."name" IN Foo

I believe changes in r7170 to are causing the problem.

Change History (2)

comment:1 Changed 10 years ago by jbronn

Description: modified (diff)

comment:2 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [7244]) queryset-refactor: Fixed the "in" lookup type when using tuples.
Accidentally broken in r7170. Fixed #6772.

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