Skip to content
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

694: search and pulldata secondary instance conflict #697

Merged
merged 4 commits into from
Feb 28, 2024

Conversation

lindsay-stevens
Copy link
Contributor

Closes #694

Why is this the best possible solution? Were any other approaches considered?

The previous solution for search + translations was pretty close, but created the possibility of conflicts in the secondary instances. This PR removes the secondary instance that would have been emitted. It also raises an error two search feature combinations that are not supported, and even if they were, would be broken by this PR's strategy (see tests for examples, where errored=True). These combinations are: 1) search appearance on a select_from_file, 2) search appearance choice list used in other selects.

An alternative detailed in #694 was to merge compatible secondary instances, but @lognaturel clarified offline that this wouldn't work because the src attribute is how Collect/Enketo identify external instances. So having choices in a secondary instances with a non-blank src wouldn't work.

What are the regression risks?

If users had forms which included the above 2 scenarios which now raise an error, they would need to fix up their form. If the error seems to harsh maybe a warning could be emitted, but ODK Validate raises an ugly error for these cases anyway (due to missing instance).

Does this change require updates to documentation? If so, please file an issue here and include the link below.

I tidied up and included some settings tests I wrote for recent forum issues. These settings could be included in the XLSForm reference template.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run python -m unittest and verified all tests pass
  • run ruff format pyxform tests and ruff check pyxform tests to lint code
  • verified that any code or assets from external sources are properly credited in comments

- search appearance was recently changed to use a secondary instance,
  to avoid the issue of missing translations. However the secondary
  instance can result in name clashes. This can be avoided by changing
  the search() select's list name to something that doesn't clash, but
  anyway the secondary instance is redundant so it is now not emitted.
- for two unsupported use cases, an error is now raised:
  - search appearance on a select_from_file
  - search appearance choice list used in other selects
- add: tests for interactions with other ways of triggering secondary
  instances e.g. pulldata, external xml/csv, select_from_file, search.
- chg: add constant for "list_name" and replace strings with it.
- add: tests for some settings that had no tests before, or were not
  well tested, or used XLS / JSON fixtures
- chg: move NSMAP constant into constants module
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hurray, that turned out not to be too bad and some nice cleanup with it too! 🎉 🙏

One message to change and a comment to consider updating as well but other than that it looks ready to me.

pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
@lognaturel
Copy link
Contributor

  1. search appearance on a select_from_file, 2) search appearance choice list used in other selects.

I don't think either of these has reasonable expected behavior and errors are an improvement. 👍

tests/test_settings.py Outdated Show resolved Hide resolved
tests/test_settings.py Outdated Show resolved Hide resolved
@lognaturel
Copy link
Contributor

These settings could be included in the XLSForm reference template

Filed settings docs issue at XLSForm/xlsform.github.io#266

@lindsay-stevens
Copy link
Contributor Author

Thanks! search() vs search is a bit confusing. I've gone with search() for the errors and clarified it in the code + tests as well.

@lindsay-stevens lindsay-stevens merged commit e57a3fd into XLSForm:master Feb 28, 2024
10 checks passed
@lindsay-stevens lindsay-stevens deleted the pyxform-694 branch February 28, 2024 12:53
@lognaturel lognaturel mentioned this pull request Apr 18, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Secondary instance generated for search() configuration likely to conflict with pulldata secondary instance
2 participants