Closed israelroldan closed 3 years ago
Thanks for the PR!
I rebased the latest master and expanded the spec to be more explicit. Do you agree with this phrasing?
Thanks for tidying it up!
The current implementation from sanity-io/groq-js#25 returns NULL_VALUE
when the expression evaluates to null
.
Would it perhaps make more sense to leave it like this? (instead of returning "null"
as the new phrasing describes) (In this way you can still use coalesce
to have a fallback if the expression evaluated to false: coalesce(string(somethingThatEvaluatesToNull), 'fallback')
as opposed to string(coalesce(somethingThatEvaluatesToNull, 'fallback'))
The current implementation also delivers cleaner objects instead of { "somethingThatEvalutesToNull": "null" }
which is consistent with GROQ's way of never returning null
as a property value
Good point. Another disadvantage of having string(null)
return "null"
is that string(string(foo))
becomes different from string(foo)
(in the case where foo
is an object).
Great, I'll fix that in the spec and re-run the build.
Merged in a124ef264d10a90304952478124de79b2ef3054c! I also added a follow-up commit to make it handle dateTime
as well.
The string function has been proposed here: https://github.com/sanity-io/groq-js/pull/25