From eda93a21edc817728bb7c1bdd31c4d0b2e5be944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 19 Jun 2020 00:18:04 +0200 Subject: [PATCH] Returns None when evaluating domain with None We implement the same behavior as SQL with NULL which always returns NULL except for IS operator. So the evaluation has the same result as the search. issue8615 review290281002 --- src/common.js | 12 ++++++++++-- tests/sao.js | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common.js b/src/common.js index 1aec8fecad..92e1ad6b36 100644 --- a/src/common.js +++ b/src/common.js @@ -2186,6 +2186,13 @@ return Boolean(context[field.split('.')[0]]); } var context_field = context[field]; + if (!~['=', '!='].indexOf(operand) && + ((context_field === null) || + (context_field === undefined) || + (value === null) || + (value === undefined))) { + return; + } if ((context_field && context_field._isAMomentObject) && !value) { if (context_field.isDateTime) { value = Sao.DateTime.min; @@ -2271,8 +2278,9 @@ } else if (domain[0] == 'OR') { return this.eval_domain(domain.slice(1), context, this.or); } else { - return boolop(this.eval_domain(domain[0], context), - this.eval_domain(domain.slice(1), context, boolop)); + return boolop(Boolean(this.eval_domain(domain[0], context)), + Boolean(this.eval_domain(domain.slice(1), context, boolop)) + ); } }, localize_domain: function(domain, field_name, strip_target) { diff --git a/tests/sao.js b/tests/sao.js index bb585e4c7c..9cc8a7540c 100644 --- a/tests/sao.js +++ b/tests/sao.js @@ -2524,10 +2524,10 @@ [ [[['x', '>', 5]], {'x': 6}, true], [[['x', '>', 5]], {'x': 4}, false], - [[['x', '>', null]], {'x': today}, true], - [[['x', '>', null]], {'x': now}, true], - [[['x', '<', today]], {'x': null}, true], - [[['x', '<', now]], {'x': null}, true], + [[['x', '>', null]], {'x': today}, false], + [[['x', '>', null]], {'x': now}, false], + [[['x', '<', today]], {'x': null}, false], + [[['x', '<', now]], {'x': null}, false], [[['x', 'in', [3, 5]]], {'x': 3}, true], [[['x', 'in', [3, 5]]], {'x': 4}, false], [[['x', 'in', [3, 5]]], {'x': [3]}, true],