New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with $replace 2nd argument #180
Comments
Thanks, Nat for the opening defect. please update once resolved |
So, while trying to simplify, I wanted to see if the $dt: expression would work... Using Tester passing in an Issue180.json containing your JSON object, I see a problem when adding the fromMillis chained function:
As the try.jsonata.org here works fine... If I rewrite without the chain function (e.g., calling the $fromMillis with the results of the $toMillis) it works: Enter jsonata expression (or q to quit): I'm not sure if I remove the chaining if this would help the parser to evaluate in the proper order or not... Enter jsonata expression (or q to quit): |
This is the parsetree for the expression:
expr { |
So, from above, it appears it wants to evaluate the line: $replace($dt, $date, $esDate) ~> $replace($month,$esMonth); I'll continue to look into this, but it may take a while... This does explain why the $toMillis function break point isn't hit before the $replace function's break point is hit. |
I was able to find and fix one bug that dealt with how I was processing the Chain (~>) function and context variables. I needed to be more specific about whether we were executing the RHS of the chain where we should expect to use a context variable, whereas on processing the LHS it would depend on the function signature being called. I also found I wasn't handling the case where we had functions on either side of the Chain function so before this expression was failing but not it is working: "$map($.NotificationData.dynamicData.flights, function($v, $i, $a){ ($dt := $toMillis($v.departure.datetimeStd) ~> $fromMillis('[FNn,-3], [D1] [MNn,-3]');) })"; Unfortunately, this still doesn't fix the overall problem where the variables are not being processed before the $replace function is being called. I've checked in the fixes I made thus far. We will need to to find a simplified expression where we have the variables being defined ahead of the $replace function but not getting processed... |
I tried the $sum function and that seemed to work fine:
Using the debugger and looking at the state of the system, the variables map doesn’t have the $date value so when attempting to get the pattern for the $replace function, it is getting a null.
I believe you are getting caught on this part of the expression:
The attempt to get the $dt value is returning null because it isn't defined:
which causes the exception you are seeing.
This is a very complicated expression, and it will take a while to try to simplify it to determine where the actual problem is getting created. I’ll try to take a look but with the holidays it will be a while.
The text was updated successfully, but these errors were encountered: