Code

Ticket #2473: in_empty_list.diff

File in_empty_list.diff, 708 bytes (added by adurdin@…, 8 years ago)
Line 
1Index: django/db/models/query.py
2===================================================================
3--- django/db/models/query.py   (revision 3518)
4+++ django/db/models/query.py   (working copy)
5@@ -641,7 +641,11 @@
6     except KeyError:
7         pass
8     if lookup_type == 'in':
9-        return '%s%s IN (%s)' % (table_prefix, field_name, ','.join(['%s' for v in value]))
10+        ids = list(value)
11+        if ids:
12+            return '%s%s IN (%s)' % (table_prefix, field_name, ','.join(['%s' for id in ids]))
13+        else:
14+            return '0'
15     elif lookup_type == 'range':
16         return '%s%s BETWEEN %%s AND %%s' % (table_prefix, field_name)
17     elif lookup_type in ('year', 'month', 'day'):