Re:Null Values in SQL Queries
by sammorrowdrums on Tuesday February 04, 2020 @07:11AM
(#22234666)
Interesting example. I certainly think the just use empty "" is fine and the coercion to NULL is not great.
I think Allowing "empty" values, and not allowing Null would be better.
If SQL had Option (Maybe) branch matching it would be an interesting replacement, and then coalesce would not be needed.
SELECT id, MATCH k WITH (
SOME(k) THEN k,
NONE THEN default,
END) AS something
FROM ...
I can see it's terse, and it is just a wrapper around data that would be stored like NULL but it kind of makes for interesting semantics.Just spitballing for fun on what it might look like.
If you really wanted to, in Haskell you could do something like: