News for hackers. Stuff that matters.
Re:SQL: The difference between WHERE and HAVING by barrkel on Tuesday December 14, 2021 @09:07AM (#29551595)
I'd hang on to NULLs, but I'd propagate nullability in the type system. That could mean disallowing anything but non-nullable boolean as filter predicates, forcing the use of COALESCE for clarity and explictness.
Re:SQL: The difference between WHERE and HAVING by wyager on Tuesday December 14, 2021 @09:19AM (#29551723)
By far the best option would be to add support for sum types and pattern matching. Besides being tremendously useful in its own right, it would also eliminate the need for nulls.
Re:SQL: The difference between WHERE and HAVING by barrkel on Tuesday December 14, 2021 @10:24AM (#29552525)
I don't think that's right; absent data is really common and a desirable feature, and ergonomically handling it warrants built-in support.

Outer joins inherently require a concept of absence of data, so you'd need a built-in Optional type which would be nullability in all but name. And you'd want lifting of operators on the inner type to the optional type for ergonomic reasons; doing a pattern match for every selection of bar.* where bar is left-joined would be extremely painful. I think you'd end up where you started on the null front.

Sum types generally, for columns etc., maybe (pun not intended), but I'm skeptical about complex types in a relational language - structure ought to be represented as relations where possible so that everything else composes.

Re:SQL: The difference between WHERE and HAVING by wyager on Tuesday December 14, 2021 @09:38PM (#29561402)
It would be ergonomic - you'd just use a variant of the equals operator specialized to Option<A> that behaved in the way you wanted.