Fix reference-geometry from repeat#848
Conversation
b55805d to
7afc951
Compare
|
Is it intended that the user-specified choice_filter completely overrides the default choice_filter expression Also I want to double check if the name/label aspect is working as expected for the secondary instance types. For the other tests there is consistently the assumption that the |
That was my intent. That filter is there because we use geometry as the item "name" and in true selects there's a crash if name is blank. But when used as reference geometry it may not matter. We wrote the spec such that malformed items should be silently skipped. So actually now that we talk this through I don't think we need a default choice filter, let me check that.
Yes, exactly. It's the same convention we established for select one from map (https://docs.getodk.org/form-question-types/#select-one-from-map-widget) We've talked about the possibility of eventually making it a third configurable reference like
Ah yes, I can add a couple here. |
Collect doesn't work without it and I'm not sure why yet. I've filed getodk/collect#7276 to get more info. |
|
When there's an absolute reference to a repeat in that same repeat, Collect automatically gives it a position predicate according to the current repeat instance. For example, The ideal would be for pyxform to generate a relative reference ( I'm surprised that I think given that we do want to get this out as soon as possible we should go with the approach with the extra predicate for now. I've added a comment to explain it. Test with relative ref |
c6800b3 to
5623262
Compare
We don't currently allow This is ready for another look with the new context! |
The Or perhaps |
|
It doesn't look like it! It would be the base path that needs to be relative, not the path of the choice filter. I played around with these ideas but couldn't figure anything out that changes things. I like that the solution in this PR is symmetrical to the same case with select one from repeat ( Line 314 in 25cb119 name != ''). We could address them both at the same time in the future.
|
|
Or do feel free to take a stab at it if you have time but I think we should aim to have something merged within 24hrs. We'll get some good feedback once people start actually using it! |
622d450 to
cb4e782
Compare
- in test_pyxform_reference__inside_repeat__ok the nodeset is an absolute reference. It may be preferable for this to be relative instead, but the test documents the current behaviour.
cb4e782 to
5c4900a
Compare
|
It looks like the absolute reference for this topology is an intentional result of #791. In that case if the reference source is inside a repeat, and the reference target is a repeat, then the reference is absolute. It was relative for some cases but that was a regression. So I'm not sure if we're talking about a specific scenario (either the case here, or the case(s) in #791) where the reference should be relative, or if we're talking about changing that design generally. Anyway, changing that would be outside of scope for this PR, so I added a test to document the behaviour and elaborated on the comment. I thought about moving the default choice_filter up into Also the test case |
|
All great additions, thank you! I thought about filing an issue to consider whether we could/should output relative references in the case of a repeat reference inside that same repeat for both geo questions and select from repeat but I'm not sure it's worth the effort and risk. Let's get some feedback on what we have now and see if there are any user needs driving further work. |
I did not look at the test output carefully enough for the nodeset reference case. This PR gets to the expected output. For selects from repeats, users specify a reference to a text field in a repeat. For reference-geometry, they specify a reference to the repeat. For now, the only field that we've said must be in the referenced repeat is
geometryso we use that asnameandlabel. In the future, we'll likely also support a mode in which a name and label can be displayed and specified, we can handle that addition then.@lindsay-stevens feel free to take this PR over if you see changes you'd like to make!
Why is this the best possible solution? Were any other approaches considered?
Overriding
_build_itemset_referencefeels like a clean use of the infrastructure in place. I verified a converted form in Collect and confirmed it works.What are the regression risks?
This is very targeted so I think the only risk is to
reference_geometryfrom repeats which doesn't currently work.Does this change require updates to documentation? If so, please file an issue here and include the link below.
Before submitting this PR, please make sure you have:
testspython -m unittestand verified all tests passruff format pyxform testsandruff check pyxform teststo lint code