Fix usage of None in search clause

review353002
This commit is contained in:
Cédric Krier
2012-05-05 09:32:24 +02:00
parent 04a5c76902
commit abb44d5703
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -119,11 +119,13 @@ class Property(Function):
break
if not default \
or (clause[2] is False and clause[1] in ['=', '!=']) \
or ((clause[2] is False or clause[2] is None)
and clause[1] in ['=', '!=']) \
or (clause[1] in ['not like', 'not ilike', 'not in', '!=']):
operator = 'in' # default operator
if ((clause[2] is False and clause[1] == '=')
or (clause[2] is not False
if (((clause[2] is False or clause[2] is None)
and clause[1] == '=')
or ((clause[2] is not False and clause[2] is not None)
and clause[1] in [
'not like', 'not ilike', 'not in', '!='])):
operator = 'not in'
@@ -161,7 +163,8 @@ class Property(Function):
operator = operator % '%%s'
return ("(CAST(SPLIT_PART(value,',',2) AS %s) IN ("
+ ",".join((operator,) * len(clause[2])) + ")) ") % sql_type
elif clause[2] is False and clause[1] in ['=', '!=']:
elif ((clause[2] is False or clause[2] is None)
and clause[1] in ['=', '!=']):
return "((cast(split_part(value,',',2) as %s) IS NULL " \
") = %%s) " % sql_type
elif clause[1] in ['not like', 'not ilike']:
@@ -179,6 +182,8 @@ class Property(Function):
res = []
if clause[1] in ('in', 'not in'):
res.extend(clause[2])
elif clause[2] is None:
res.append(False)
else:
res.append(clause[2])
return res
+1 -1
View File
@@ -1554,7 +1554,7 @@ class ModelSQL(ModelStorage):
domain[i] = ('id', 'not in', ids2 + _rec_get(ids2,
table, domain[i][0]))
else:
if isinstance(domain[i][2], bool):
if isinstance(domain[i][2], bool) or domain[i][2] is None:
relation_obj = pool.get(field.relation_name)
query1 = 'SELECT "' + field.origin + '" ' \
'FROM "' + relation_obj._table + '" '\