Domain evaluation : Conditions like [(field,'in',[])],[(field,'not in',[])] considered
lp bug: https://launchpad.net/bugs/504584 fixed bzr revid: jvo@tinyerp.com-20100108081408-rtkmra85ckasboob
This commit is contained in:
parent
b4867291bb
commit
91a867f9de
|
@ -333,7 +333,7 @@ class expression(object):
|
|||
query = '(%s.%s in (%s))' % (table._table, left, right[0])
|
||||
params = right[1]
|
||||
elif operator in ['in', 'not in']:
|
||||
params = right[:]
|
||||
params = right and right[:] or []
|
||||
len_before = len(params)
|
||||
for i in range(len_before)[::-1]:
|
||||
if params[i] == False:
|
||||
|
@ -342,14 +342,19 @@ class expression(object):
|
|||
len_after = len(params)
|
||||
check_nulls = len_after != len_before
|
||||
query = '(1=0)'
|
||||
|
||||
|
||||
if len_after:
|
||||
if left == 'id':
|
||||
instr = ','.join(['%s'] * len_after)
|
||||
else:
|
||||
instr = ','.join([table._columns[left]._symbol_set[0]] * len_after)
|
||||
query = '(%s.%s %s (%s))' % (table._table, left, operator, instr)
|
||||
|
||||
else:
|
||||
# the case for [field, 'in', []] or [left, 'not in', []]
|
||||
if operator == 'in':
|
||||
query = '(%s.%s IS NULL)' % (table._table, left)
|
||||
else:
|
||||
query = '(%s.%s IS NOT NULL)' % (table._table, left)
|
||||
if check_nulls:
|
||||
query = '(%s OR %s.%s IS NULL)' % (query, table._table, left)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue