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
This commit is contained in:
Cédric Krier
2020-06-19 00:18:04 +02:00
parent 815cc31e66
commit eda93a21ed
2 changed files with 14 additions and 6 deletions
+10 -2
View File
@@ -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) {
+4 -4
View File
@@ -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],