From 7fbebbf3611050aeb74a1aa61f5e16c912d65713 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Fri, 27 May 2022 11:44:56 +0900 Subject: [PATCH 1/2] fix JSONata evaluation of inject button --- .../node_modules/@node-red/nodes/core/common/20-inject.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/common/20-inject.js b/packages/node_modules/@node-red/nodes/core/common/20-inject.js index 92b8122df..734bce765 100644 --- a/packages/node_modules/@node-red/nodes/core/common/20-inject.js +++ b/packages/node_modules/@node-red/nodes/core/common/20-inject.js @@ -109,9 +109,10 @@ module.exports = function(RED) { if (!property) return; if (valueType === "jsonata") { - if (p.exp) { + if (p.v) { try { - var val = RED.util.evaluateJSONataExpression(p.exp, msg); + var exp = RED.util.prepareJSONataExpression(p.v, node); + var val = RED.util.evaluateJSONataExpression(exp, msg); RED.util.setMessageProperty(msg, property, val, true); } catch (err) { From 7e6dfa7b927a513dea3c28beabc6b760e078748e Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Fri, 27 May 2022 12:11:53 +0900 Subject: [PATCH 2/2] update test for inject node --- test/nodes/core/common/20-inject_spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/nodes/core/common/20-inject_spec.js b/test/nodes/core/common/20-inject_spec.js index cb14690d0..a4dbdd9e4 100644 --- a/test/nodes/core/common/20-inject_spec.js +++ b/test/nodes/core/common/20-inject_spec.js @@ -906,6 +906,7 @@ describe('inject node', function() { msg.should.have.property("str1", "1"); //injected prop msg.should.have.property("num1", 1); //injected prop msg.should.have.property("bool1", true); //injected prop + msg.should.have.property("jsonata1", "AB"); //injected prop helper.clearFlows().then(function() { done(); @@ -919,6 +920,7 @@ describe('inject node', function() { {p:"str1", v:"1", vt:"str"}, //new prop {p:"num1", v:"1", vt:"num"}, //new prop {p:"bool1", v:"true", vt:"bool"}, //new prop + {p:"jsonata1", v:'"A" & "B"', vt:"jsonata"}, //new prop ]}) .expect(200).end(function(err) { if (err) {