Fix: Complex jexl issues (refactor(forms): rewrite structure and jexl evaluator) #2356
+2,335
−751
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refactor(forms): rewrite structure and jexl evaluator
The new structure / jexl evaluator works a bit differently: Instead of
trying to replace evaluation contexts during recursive evaluation (for
example
is_hidden
checks), we now have a local JEXL runtime for eachfield. Also, the JEXL expressions (or their results, rather) are heavily
cached and should speed things up significantly.
Regarding the test cases:
We're trying to keep the test cases' meaning 100% unchanged - the only
modifications currently are some improved assertion messages, so
debugging becomes easier, as well as refactoring some for better readability.
Some tests are extended, and some are now better documented, to cover
more aspects and explain in more detail what our assumptions and
expectations actually are.
BREAKING CHANGE: Code that uses the form jexl and / or structure code
most likely will need to be rewritten. The changes are small-ish, but
still semantically not exactly equal.
refactor: rewrite the calculated-question code to use the new structure
The whole updating code for calculated fields was rather complex and
had quite a few subtle bugs. With the new structure, we have infrastructure
in place to build the same behaviour in a much better, more reliable way.