Opened 17 years ago

Closed 17 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: no UI/UX: no

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/query.py", line 28, in __repr__
    return repr(list(iter(self)))
  File "/Users/jbronn/django/queryset-refactor/django/db/models/query.py", line 46, in __iter__
    self._fill_cache()
  File "/Users/jbronn/django/queryset-refactor/django/db/models/query.py", line 446, in _fill_cache
    self._result_cache.append(self._iter.next())
  File "/Users/jbronn/django/queryset-refactor/django/db/models/query.py", line 127, in iterator
    for row in self.query.results_iter():
  File "/Users/jbronn/django/queryset-refactor/django/db/models/sql/query.py", line 163, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/Users/jbronn/django/queryset-refactor/django/db/models/sql/query.py", line 1301, in execute_sql
    cursor.execute(sql, params)
  File "/Users/jbronn/django/queryset-refactor/django/db/backends/util.py", 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 where.py are causing the problem.

Change History (2)

comment:1 by jbronn, 17 years ago

Description: modified (diff)

comment:2 by Malcolm Tredinnick, 17 years ago

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