Closed mattes3 closed 7 months ago
The place in the code seems to be here: https://github.com/parcelvoy/platform/blob/572d8f7d7cbab7c3faefb54b5e672b85ff46cc46/apps/platform/src/rules/RuleHelpers.ts#L9
Looks like there is an incongruity in how MySQL and JS can evaluate JSON paths. JS does not allow dot syntax paths to start with a number but MySQL does and the paths come from a MySQL generated query. Unfortunately it's going to be a fairly involved problem to solve for since there can be a ton of edge cases. For now, you don't have to use the provided options in the dropdowns, you can type your own path so I would recommend that approach and manually enter $['2q2m_status']
in the field until we can find an approach that doesn't break other functionality
Unfortunately, this workaround won't work. When I write $['2q2m_status']
then the if-statement in RuleHelpers.ts
adds '$.' in front of it:
if (!path.startsWith('$.')) path = '$.' + path
Since RuleHelper.ts
does this, I thought it would be a good place to replace $.something
by $['something']
which would be exactly equivalent in JsonPath language. Like so:
path = path.replace(/\$\.(.*?)\b/g, "$['$1']")
We ended up adding logic to detect keys that aren't valid JS syntax during the path suggestions generation and instead replace them with bracket syntax. You'll need to re-generate the suggestions (you can do this now with a button inside of the project settings page). We've also resolved not being able to manually enter that as well due to that line
Thanks a lot, it works like charm now.
I tried to create a dynamic list with a criterion that looks like
$.2q2m_status equals "signed_up"
.When I use a field name that starts with a letter, it works. However when it starts with a number, I get this error message in the log:
Maybe you could change the code from
$.2q2m_status
to$['2q2m_status']
to make the error go away?