-
Notifications
You must be signed in to change notification settings - Fork 138
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
Secondary instance generated for search() configuration likely to conflict with pulldata secondary instance #694
Comments
Well, I had my test runs configured wrong so I got convinced we could just not ever have an itemset defined: #695 That breaks translations, though, so is no-go. @lindsay-stevens any chance you have quick ideas? Sorry we're still running into issues around this! |
The below test which omits There is already a fair bit of special handling for So my suggested fix would be to add some tests to document this behaviour, and maybe update the examples to use unique names (other than "fruits"). def test_choice_and_pulldata(self):
md = """
| survey | | | | |
| | type | name | label | calculation |
| | select_one c1 | q1 | Question 1 | |
| | calculate | calc | | pulldata('c1', 'this', 'that', ${q1}) |
| choices | | | |
| | list_name | name | label |
| | c1 | na | la |
"""
self.assertPyxformXform(
md=md,
xml__xpath_match=[
"/h:html/h:body/x:select1/x:item[./x:value/text()='na']"
],
) |
I don’t disagree with anything you wrote! I do find it really hard to break existing forms, though. The user who reported this was extremely confused and wasted quite a bit of time trying to find other solutions. Selecting something from a list with search() and then getting one of its properties with pulldata() is a common pattern when using those two. How did this work before pyxform 2? There was no itemset set for selects with search(). Somehow translations were still generated, though? And a secondary instance was created, it just bypassed the check for duplicates somehow? I’m ok for waiting to see how often it comes up before we decide what to do. My guess is that it will get reported a lot once some downstream tools that recommend search()/pulldata() upgrade. |
Prior to pyxform 2.0:
Maybe In other words, use the secondary instance that would be generated for the <instance id="fruits" src="jr://file-csv/fruits.csv">
<root>
<item>
<itextId>fruits-0</itextId>
<name>na</name>
</item>
</root>
</instance> In the below table I'm guessing how and when this change could work in combination with other sources of secondary instances, specifically when the instance name referenced by
This could be a way to get CSV external instances to support translations, because |
Software and hardware versions
pyxform v2.0.2
Problem description
The fix for #690 led to secondary instances being generated for the choice list used to configure
search()
. That can lead to an error if the name of that list is the same as the name of the CSV. Unfortunately, that's the pattern documented at https://xlsform.org/en/#dynamic-selects-from-pre-loaded-data so I imagine it's common.Steps to reproduce the problem
See the error:
Expected behavior
No error.
Other information
Could we do something hacky like add a uuid to the secondary instance name if it's hard not to produce it? I don't think it's used for anything.
The text was updated successfully, but these errors were encountered: