changeset 579d0ce4a305 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=579d0ce4a305
description:
        Manage None as value of PYSON In

        issue11280
        review393771002
diffstat:

 src/pyson.js |  10 +++++++---
 tests/sao.js |   6 ++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 0461c402cba7 -r 579d0ce4a305 src/pyson.js
--- a/src/pyson.js      Sun Mar 06 13:42:04 2022 +0100
+++ b/src/pyson.js      Sun Mar 06 18:02:00 2022 +0100
@@ -693,10 +693,14 @@
     });
 
     Sao.PYSON.In.eval_ = function(value, context) {
-        if (value.v.indexOf) {
-            return Boolean(~value.v.indexOf(value.k));
+        if (value.v) {
+            if (value.v.indexOf) {
+                return Boolean(~value.v.indexOf(value.k));
+            } else {
+                return !!value.v[value.k];
+            }
         } else {
-            return !!value.v[value.k];
+            return false;
         }
     };
     Sao.PYSON.In.init_from_object = function(obj) {
diff -r 0461c402cba7 -r 579d0ce4a305 tests/sao.js
--- a/tests/sao.js      Sun Mar 06 13:42:04 2022 +0100
+++ b/tests/sao.js      Sun Mar 06 18:02:00 2022 +0100
@@ -782,6 +782,12 @@
             new Sao.PYSON.In('test', []));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
                 "decode(In('test', []))");
+
+        eval_ = new Sao.PYSON.Encoder().encode(
+            new Sao.PYSON.In('test', new Sao.PYSON.Eval('foo', [])));
+        QUnit.strictEqual(new Sao.PYSON.Decoder({'foo': null}).decode(eval_),
+            false, "decode(In('test', Eval('foo', [])))");
+
         QUnit.strictEqual(new Sao.PYSON.In('foo', ['foo', 'bar']).toString(),
                 'In("foo", ["foo", "bar"])');
     });

Reply via email to