Hacker News new | ask | show | jobs
by setr 845 days ago
You’d have to unwrap, usually with convenient mechanism for it —pattern matching

The problem is that id = id is fundamentally incorrect for a nullable column. You should have done id is not null and id = id. And you shouldn’t have been allowed to do the first anyways, because nothing good can come of it (there is no sane semantics to stuffing a trinary logic into a boolean algebra, and SQL chooses one of the many insane options, leading to both false positive and false negative matches depending.) the only correct answer is not to do that.

1 comments

I can understand how that would make things more explicit - but given how common nullability is in the realm of databases I think it'd be a bad idea to force that much syntax in a situation where id=id is essentially what we want to discuss - especially since columns becoming potentially null is so trivial to achieve (even when impossible due to model constraints) as soon as you start throwing left joins in the mix.
Sometimes you really want explicit, rather than dealing with the errors caused by implicitness. And with a language that has proper support for things like Maybe, there isn't that much syntax.

It's true that you have to adopt a completely different language, but when that language saves you from potentially expensive bugs, it becomes appealing.