changeset a8da0a7e0c3d in sao:6.2
details: https://hg.tryton.org/sao?cmd=changeset&node=a8da0a7e0c3d
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 3388595bf668 -r a8da0a7e0c3d 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
@@ -682,10 +682,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 3388595bf668 -r a8da0a7e0c3d 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"])');
});