Hacker News new | ask | show | jobs
by letstryagain 3881 days ago
Ideally you'd want your RDBMS to refuse to compile tests like x = y in cases where either x or y could be null. You would have to explicitly handle nulls in boolean statements.
2 comments

That would be sensible if SQL dialects usually offered a sane comparison that returns true/false reasonably for null comparisons. Since they don't, and = is the only available equality test, I'm going to stick to my original point that null comparison in SQL is dumb and wrong for 99% of use-cases and compiler warnings would be solving the wrong problem.
MySql, Postgres, and Vertica, at least, all support <=> as an operator that treats NULL as an ordinary, distinct value.
I've been working on a linter for SQL - that's probably not a bad rule to toss in the mix...