Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unless you're using an ORM that is replacing "= NULL" to "IS NULL" for you, you should know that there's a configuration within Postgres to change to do so instead: https://postgresqlco.nf/en/doc/param/transform_null_equals/


I don't recommend that setting, personally. If you do use it, I recommend it only for migration purposes with the idea that you go back to the default setting soon.

Configuration settings that change SQL semantics are just too dangerous.

From the official docs:

"Note that this option only affects the exact form = NULL, not other comparison operators or other expressions that are computationally equivalent to some expression involving the equals operator (such as IN). Thus, this option is not a general fix for bad programming."

https://www.postgresql.org/docs/12/runtime-config-compatible...

I know it seems tempting to use this setting as a convenience, but I strongly recommend against it.


Thanks. "= NULL" is not benign, either. It causes its own set of issues.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: