Ticket #3053: django_empty_set_in_where.patch

File django_empty_set_in_where.patch, 738 bytes (added by Zoltan Arokszallasi <godri@…>, 9 years ago)
  • db/models/query.py

    diff -ruN django.branch/db/models/query.py django/db/models/query.py
    old new  
    662662    except KeyError:
    663663        pass
    664664    if lookup_type == 'in':
    665         return '%s%s IN (%s)' % (table_prefix, field_name, ','.join(['%s' for v in value]))
     665        if value:
     666            value_set = ','.join(['%s' for v in value])
     667        else:
     668            value_set = 'NULL'
     669        return '%s%s IN (%s)' % (table_prefix, field_name, value_set)
    666670    elif lookup_type == 'range':
    667671        return '%s%s BETWEEN %%s AND %%s' % (table_prefix, field_name)
    668672    elif lookup_type in ('year', 'month', 'day'):
Back to Top