JSONata Transform Operator: Unexpected change in variable binding? between versions 1.8.6 and 2.0.3

117 Views Asked by At

My business relies on the transform operator to manipulate prices according to the age of products, I therefore calculate an age for every product, then deduce its rebate rate and finally its new price. This has worked in the past (I THINK) by manipulating inventory with the transform operator together with inline variable assignments. Now by chance I came across a problem when I tried to use the chain operator together with inline variable assignments.

Long story, here's what I have narrowed the issue down to:

On https://try.jsonata.org/

set as data:

[
  {
    "a": 1
  },
  {
    "a": 2
  }
]

and as query:

$ ~> | $ | {
    "b": $c := a,
    "c": $c
} |

Now you get different answers depending on the JSONata version.

Up to 1.3.3, you get an error, THIS IS UNDERSTANDABLE. From 1.4.1 to 1.8.6, you get this answer, which I expected:

[
  {
    "a": 1,
    "b": 1,
    "c": 1
  },
  {
    "a": 2,
    "b": 2,
    "c": 2
  }
]

BUT for version 2.0.3, you get an answer that frustrates me:

[
  {
    "a": 1,
    "b": 1
  },
  {
    "a": 2,
    "b": 2,
    "c": 1
  }
]

Why is that, and how can I find out, which JSONata my Nodered uses in its change nodes?

Thank you for any insight, Sebastian

0

There are 0 best solutions below