changeset b34b1daf66ea in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset&node=b34b1daf66ea
description:
Manage None as value of PYSON In
issue11280
review393771002
(grafted from 579d0ce4a3056c2ec60e4c208c2a8cd7e7824210)
diffstat:
src/pyson.js | 10 +++++++---
tests/sao.js | 6 ++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diffs (37 lines):
diff -r 33cb34c6d49b -r b34b1daf66ea src/pyson.js
--- a/src/pyson.js Wed Feb 23 17:15:26 2022 +0100
+++ b/src/pyson.js Sun Mar 06 18:02:00 2022 +0100
@@ -643,10 +643,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 33cb34c6d49b -r b34b1daf66ea tests/sao.js
--- a/tests/sao.js Wed Feb 23 17:15:26 2022 +0100
+++ b/tests/sao.js Sun Mar 06 18:02:00 2022 +0100
@@ -647,6 +647,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"])');
});