Added a substring test case for an empty string and zero index.#55
Added a substring test case for an empty string and zero index.#55evan-gordon wants to merge 1 commit intocqframework:mainfrom
Conversation
|
I agree the SubString documentation, https://cql.hl7.org/09-b-cqlreference.html#substring, is a bit vague. The key is the line What is meant by Does an empty string have a range since it is length zero? I'd say there is no range hence any value for startIndex will be out or range. So the expected behavior, using my interpretation, is that substring should return null for an empty string. That being said, looking at how other languages treat substring applied to an empty string
Should CQL follow the 'common' convention and return an empty string? |
|
I agree that the spec as written does best support the Will not always hold true, which I find a bit odd. That said, it's probably not a big deal either way in practice so more of a definition thing and something worth adding a spec test for (whichever way we decide). I don't feel super strongly either way personally, but lean towards the empty string return. I figured it was worth some quick discussion! |
From looking at the docs it was a bit unclear if this case should return empty string or null, but empty string made the most sense to me. Happy to discuss this further.
Related to @suyashkumar 's changes in google/cql#117