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

add new number-or-zero() XPath function #388

Closed
wants to merge 2 commits into from
Closed

add new number-or-zero() XPath function #388

wants to merge 2 commits into from

Conversation

tiritea
Copy link
Contributor

@tiritea tiritea commented Nov 27, 2018

Returns 0 instead of NaN if argument is not a valid numeric expression, eg number-or-zero(${foo})

Specifically intended to replace the more long-winded coalesce(${foo},0) or if(${foo}!='',${foo},0)

Closes #

What has been done to verify that this works as intended?

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

this solution is intended to make more 'complicated' solutions less necessary or prone to user mistakes.

Are there any risks to merging this code? If so, what are they?

Shouldnt be - this new XPath function wont ever get used unless explicitly added to XForm expression by form writer. So will not affect any existing forms.

Returns 0 instead of NaN if argument is not a valid numeric expression, eg number-or-zero(${foo})

 Specifically intended to replace the more long-winded coalesce(${foo},0) or if(${foo}!='',${foo},0)
@tiritea
Copy link
Contributor Author

tiritea commented Nov 27, 2018

First ODK PR! Please be gentle... ;-)

D'oh. will fix...

Copy link
Contributor Author

@tiritea tiritea left a comment

Choose a reason for hiding this comment

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

stupid mistake

@codecov-io
Copy link

Codecov Report

Merging #388 into master will decrease coverage by 0.03%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #388      +/-   ##
============================================
- Coverage     48.31%   48.27%   -0.04%     
+ Complexity     2869     2868       -1     
============================================
  Files           239      239              
  Lines         13506    13512       +6     
  Branches       2621     2623       +2     
============================================
- Hits           6525     6523       -2     
- Misses         6146     6152       +6     
- Partials        835      837       +2
Impacted Files Coverage Δ Complexity Δ
src/org/javarosa/xpath/expr/XPathFuncExpr.java 53.99% <0%> (-0.53%) 158 <0> (ø)
...c/org/javarosa/core/services/PrototypeManager.java 79.16% <0%> (-8.34%) 8% <0%> (-1%)

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 342c58d...3fa81f9. Read the comment docs.

@tiritea
Copy link
Contributor Author

tiritea commented Nov 28, 2018

FYI would imply corresponding function added to Enketo XPath (@MartijnR)

@tiritea tiritea closed this Dec 19, 2018
@tiritea tiritea deleted the patch-1 branch December 19, 2018 22:41
@tiritea
Copy link
Contributor Author

tiritea commented Dec 19, 2018

Cancelled per discussion on ODK Forum; https://forum.opendatakit.org/t/new-number-or-zero-xpath-function/15975

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.

None yet

2 participants