r/programming • u/winsletts • Sep 02 '26
Postgres Calculations and the Ambiguity of NULL
https://www.crunchydata.com/blog/postgres-calculations-and-the-ambiguity-of-nullAll the ways that NULL can cause chaos in your SQL outcomes.
125
Upvotes
37
u/iamemhn Sep 02 '26
Welcome to 1975 and algebraic bottom values, I guess... 🤣
71
u/robotmayo Sep 02 '26
A boolean in many languages having 3 states: True, False, Null is one of my favorite things about programming. Its so funny to me.
22
u/Gropah Sep 02 '26 edited Sep 03 '26
I still hate oracle for thinking in their infinite wisdom to store an empty string as null because those are clearly the same, while knowing the column is not nullable.
(and no, that's not the same as the concat function treating null as an empty string)
27
u/qqwy Sep 02 '26
And finally, many ORMs pretend that the SQL
NULLworks the same asNone/nil/nullin Python/Ruby/JavaScript etc, but this is a big footgun: they show very different behavior.5
u/renges Sep 03 '26
I had to do an essay on relational Theory in the university and read C. J. Date's book about how relational database are not really relational. In there, he explained that relational theory and set theory are used to represent reality and that the concept of NULL does not exist in relational theory because you can't represent a non existent value in reality. I'd really recommend anyone to read his book if you're curious into the difference between relational theory and a not so relational database