XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
77 stars 134 forks source link

Fixed indexed-repeat argument path evaluation in integer column type #499

Closed gushil closed 3 years ago

gushil commented 3 years ago

Closes #484 Closes #507

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

Previous solution (PR #485) with added evaluation for integer type column.

What are the regression risks?

None.

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

No.

Before submitting this PR, please make sure you have:

codecov-io commented 3 years ago

Codecov Report

Merging #499 (211d575) into master (94dc5a2) will decrease coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #499      +/-   ##
==========================================
- Coverage   83.86%   83.85%   -0.01%     
==========================================
  Files          25       25              
  Lines        3693     3691       -2     
  Branches      860      859       -1     
==========================================
- Hits         3097     3095       -2     
  Misses        452      452              
  Partials      144      144              
Impacted Files Coverage Δ
pyxform/survey.py 92.87% <100.00%> (-0.03%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 94dc5a2...211d575. Read the comment docs.

lognaturel commented 3 years ago

This doesn't look right. It will keep failing for every type other than text or integer which is not what we want. I think the difference in behavior is between calculates and non-calculates so perhaps that condition should be if context["type"] != "calculate". But I think there's also something wrong with the else branch because it doesn't account for typed calculates. Should it maybe just be return not("indexed-repeat" in context["bind"]["calculate"])?

gushil commented 3 years ago

@lognaturel I've made the changes you suggested and all the tests are passed.

Thanks!

gushil commented 3 years ago

@lognaturel

Paul told me a couple of indexed-repeat expressions that could cause an issue, like indexed-repeat inside an if-else, or indexed-repeat as an expression, or indexed-repeat as an argument in other function like concat(), substr().

I think those cases are already tested, right?

In the previous commit I've already removed the branching statement, please review it.

Thanks!

gushil commented 3 years ago

@lognaturel

Still waiting for your review/resolve.

Thanks!

lognaturel commented 3 years ago

Happy New Year and I'll try to take a look by the end of the week. Please see #507 for a new test to add.

MartijnR commented 3 years ago

Thanks @lognaturel and @gushil!