From 91a867f9de43c5124315d75dfcc201df991cc307 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Fri, 8 Jan 2010 13:44:08 +0530 Subject: [PATCH] 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 --- bin/osv/expression.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/osv/expression.py b/bin/osv/expression.py index a78bf3ca9f5..8c4bd589d44 100644 --- a/bin/osv/expression.py +++ b/bin/osv/expression.py @@ -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: