-
Notifications
You must be signed in to change notification settings - Fork 137
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
Add support for entity updates #664
Conversation
7f536bf
to
fac4627
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stepped through the spec, truth table, and code and it seems to all check out - so, great! I approve. I added a few minor suggestion comments.
I think it's worth considering calling the validation logic from EntityDeclaration
(during XML processing) either in addition to or instead of from workbook_to_json
. A key benefit to checking during the latter is that it's possible to tell the user where they made a mistake in the XLSForm, but users can only have 1 entity per form so that is kind of redundant. Also by calling the validation during the XML pipeline it can apply to data coming in via the JSON entrypoint to pyxform (e.g. builder.py
).
Thanks so much for the thorough review, all the great suggestions, and particularly for catching that the spec change should be versioned. 🙏 Since I ended up making substantive changes I'd prefer one last sanity check on the last three commits, please! Feel free to merge if you're happy with that.
This is an interesting suggestion that I'd rather chew on and address in a follow-up PR.
The current messages use a lot of spreadsheet language too.
Do we know that it's for sure being used? |
Thanks! To summarise the related slack thread, the behaviour in this PR is that if a XLSForm uses entity updates then it gets the newer spec version |
Closes #662
Why is this the best possible solution? Were any other approaches considered?
The complexity here comes from the fact that the spec allows for implicit actions. Specifically:
dataset
andlabel
specified, it's implied that submissions should always create entitiesentity_id
is specified, it's implied that submissions should always update entitiesThat makes the implementation more complex but I continue to think it's worth it because it's more intuitive than having to explicitly specify
true()
as create or update conditions.Given that complexity, I decided to pass through the XLSForm values in the json representation (
entities_parsing
) and then to handle all the cases when building the XML representation (entity_declaration
).I used a truth table to make sure I handled and tested all the combinations of
entity_id
,create_if
andupdate_if
:Hopefully that also helps with review.
I did find it challenging to balance writing narrow, specific tests and feeling confident that all aspects of the form were taken care of with each combination of options.
What are the regression risks?
There's some possible regression risk around entity creation. Hopefully the tests guard against it! The bigger risk is that I have a logic error in the new code.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Part of getodk/docs#1678
Before submitting this PR, please make sure you have:
tests
nosetests
and verified all tests passblack pyxform tests
to format code