fix parsing of (multiple) pulldata calls in a (multi-line) expression #547
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.
Closes #509
Why is this the best possible solution? Were any other approaches considered?
Users may wish to format their large / complex expressions with newlines and still utilise the
pulldata()
function. It seems most XLSForm documentation and examples showpulldata
used on its own in an expression. However the existing testtest_external_instance_pulldata_constraint_in_expression
shows thatpulldata
is valid as part of compound expressions. It may be a bit unusual but there seems to be no technical reason why an expression could not use multiplepulldata
calls. These changes result in support for multi-line formatted expressions, and multiplepulldata
calls in an expression.Alternatives may be to raise an error if a) multi-line formatting or b) multiple
pulldata
calls are detected in an expression. However there seems no spec or technical reason to forbid these usages.What are the regression risks?
It may be that some XForm collectors / tools do not support expressions with line breaks, or multiple
pulldata
calls. In which case these applications could check for these and reject the form design. The current changes are accepted by ODK Validate so presumably they are OK.Does this change require updates to documentation? If so, please file an issue here and include the link below.
No, they seem to be consistent with the documentation. The section "How to pull data from CSV" refers to
pulldata
as a function, so it's reasonable to assume from that that it could be used more than once in an expression.Before submitting this PR, please make sure you have:
tests_v1
nosetests
and verified all tests passblack pyxform
to format code