Hi all,
Regarding the recent 1111-feel-matches-function.dmn PR. It has a number of tests in it that use a null value where an optional function parameter is specified .. like this: matches("abracadabra", "bra", null). The last parameter is defined by the spec as an optional string value.
Some of the tests are asserting passing a null value is the same as having actually not passed a value at all, like treating matches("abracadabra", "bra", null) as if it were really matches("abracadabra", "bra"). They're good tests and are specifically testing for that situation. Cool. Looking at other tests where there are optional params it looks we may have totally missed this assertion - certainly I have missed it in a number of test suites I have submitted - mea culpa.
My take on this is they are not the same and the actual return value should be null. That is, with an invocation like matches("abracadabra", "bra", null) .. it actually is passing a value to the function ... it has provided a null where there are specific domain constraints. In this case it is not a valid value, therefore, it is an invalid argument.
pattern, replacement, and flags SHALL conform to the syntax and constraints specified in clause 7.6 of XQuery
1.0 and XPath 2.0 Functions and Operators.
A null does not conform to the above. (or does it?! - opinions welcome!).
IMO, if you actually pass an argument it must match the parameter domain constraints - if not, the result should be null. And passing null is not the same as not passing an argument.
If the spec says otherwise, cool - lemme know. It would not be the first (or last!) time I am wrong, but, I feel there is a difference between passing a null value as an optional value, and not actually passing a value.
Greg.
Hi all,
Regarding the recent
1111-feel-matches-function.dmnPR. It has a number of tests in it that use anullvalue where an optional function parameter is specified .. like this:matches("abracadabra", "bra", null). The last parameter is defined by the spec as an optional string value.Some of the tests are asserting passing a null value is the same as having actually not passed a value at all, like treating
matches("abracadabra", "bra", null)as if it were reallymatches("abracadabra", "bra"). They're good tests and are specifically testing for that situation. Cool. Looking at other tests where there are optional params it looks we may have totally missed this assertion - certainly I have missed it in a number of test suites I have submitted - mea culpa.My take on this is they are not the same and the actual return value should be
null. That is, with an invocation likematches("abracadabra", "bra", null).. it actually is passing a value to the function ... it has provided anullwhere there are specific domain constraints. In this case it is not a valid value, therefore, it is an invalid argument.A
nulldoes not conform to the above. (or does it?! - opinions welcome!).IMO, if you actually pass an argument it must match the parameter domain constraints - if not, the result should be
null. And passingnullis not the same as not passing an argument.If the spec says otherwise, cool - lemme know. It would not be the first (or last!) time I am wrong, but, I feel there is a difference between passing a null value as an optional value, and not actually passing a value.
Greg.