Open jfmcquade opened 11 months ago
Just to copy from previous PR thread/add clarity
Ah, yeah I see the challenge here - comparing the two cases:
hello @field.name
@field.name.startsWith("A")
In case (1) we want the string to just replace and return hello my_name
In case (2) we want the string to replace wrapped as a string "my_name".startsWith("A")
Currently we focus on supporting case (1). The parser attempts to evaluate, but reads hello
and my_name
as variables which are not defined, and has a fallback in case of such errors to just return the full expression as-is (as text)
I think the best way to also support case (2) would be to internally store a mapping of replaced strings when evaluating, which can then be used in follow-ups. E.g. for both cases above the mapping would simply be variables
{my_name: "my_name"}
Then when it comes to evaluation, case 1 will still just return as text (failing to recognise hello
as a variable), but case 2 should be able to parse my_name.startsWith("A")
, substituting the my_name
variable for "my_name"
string
I'll try make these changes in a follow-up PR as not so much targetted on the issue at hand
As highlighted in #2107, the evaluator
AppDataVariableService
introduced in #2040 does not handle string values correctly. See tests added to src/app/shared/services/data/app-data-variable.service.spec.tsCompare to
appStringEvaluator.evaluate()
method found inpackages/shared/src/models/appStringEvaluator/appStringEvaluator.ts
, which explicitly adds string delimiters.