From 8eac7634e23d799fc2a0b790cfe3a37e63e88754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 3 Feb 2024 19:29:59 +0100 Subject: [PATCH] Return new instances of PYSON object from PYSON shortcut methods Closes #12985 (grafted from af58504c1e6ad2b17cac5b6c41454d7eda28c5c7) --HG-- branch : 6.0 --- sao/src/pyson.js | 6 +++--- sao/tests/sao.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sao/src/pyson.js b/sao/src/pyson.js index a63166f5a7..58d965a333 100644 --- a/sao/src/pyson.js +++ b/sao/src/pyson.js @@ -36,13 +36,13 @@ if (d === undefined) { d = ''; } - return Sao.PYSON.Get(this, k, d); + return new Sao.PYSON.Get(this, k, d); }, in_: function(obj) { - return Sao.PYSON.In(this, obj); + return new Sao.PYSON.In(this, obj); }, contains: function(k) { - return Sao.PYSON.In(k, this); + return new Sao.PYSON.In(k, this); }, toString: function() { var klass = this.pyson().__class__; diff --git a/sao/tests/sao.js b/sao/tests/sao.js index c64e7efcbe..4fef0368d0 100644 --- a/sao/tests/sao.js +++ b/sao/tests/sao.js @@ -1263,6 +1263,9 @@ QUnit.strictEqual( eval_pyson('Or(True, False).toString()'), "Or(true, false)", "eval_pyson('Or(True, False)').toString()"); + QUnit.strictEqual( + eval_pyson('Eval("foo", {}).get("bar").toString()'), + 'Get(Eval("foo", {}), "bar", "")'); }); QUnit.test('DomainParser.group_operator', function() {