changeset becbdd5a8e5e in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=becbdd5a8e5e
description:
        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
diffstat:

 src/common.js |  12 ++++++++++--
 tests/sao.js  |   8 ++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diffs (47 lines):

diff -r 297c4f453043 -r becbdd5a8e5e src/common.js
--- a/src/common.js     Wed Jun 17 13:51:41 2020 +0200
+++ b/src/common.js     Fri Jun 19 00:18:04 2020 +0200
@@ -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 -r 297c4f453043 -r becbdd5a8e5e tests/sao.js
--- a/tests/sao.js      Wed Jun 17 13:51:41 2020 +0200
+++ b/tests/sao.js      Fri Jun 19 00:18:04 2020 +0200
@@ -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],

Reply via email to