jsonata-js / jsonata

JSONata query and transformation language - http://jsonata.org
MIT License
2.09k stars 220 forks source link

Issue - variables set in $merge are referencing the wrong iteration value #640

Open thekingofspain opened 1 year ago

thekingofspain commented 1 year ago

I am seeing a different behavior in my jsonata application between versions 2.0.1 and 2.0.3 around how variables are referenced within the $merge function where the merge function is calling other functions and setting variables. The 2.0.1 version is the behavior that I am expecting and what I believe to be the proper result.

2.0.1 Example

2.0.3 Example

The jsonata application is performing...

  1. A left join between Si.SiGridRow.BaId and Sn.AppId
  2. If there is match, then calculate Icon characters for a new json object called Conflicts.

The 2.0.3 Example is applying the Conflicts object calculated for output array item n to output array item n + 1, while the 2.0.1 example is applying the Conflicts object for the output array item n to the output array item n itself.

thekingofspain commented 1 year ago

I rolled back to 2.0.1 and the problem reproduces for me locally. Not exactly sure what is different between stedi jsonata 2.0.1 and github 2.0.1 min. Setting jsonata to version 1.8.6 returns the expected results(stedi 2.0.1 example) in the playground.