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

Who comes up with an argument for considering nulls distinct??

Imagine a programming language where `if (variable == null)` always returned `false` because nulls were considered distinct. What kind of reasoning goes into thinking that's a great idea?

> If nulls are considered distinct, then having more than one of them won’t cause a unique constraint violation.

Gosh, I would've thought the spec was fine as it was, having to spell out that the DB should consider two null values equivalent for UNIQUENES constraints is like spelling out that "two integers that have the same mathematical value should be considered equivalent". I guess they need to add that in the spec if it's missing as well.



NULL is more of a declaration that 'there is no value', than mathematical value on its own. if you compare NULL with something you don't get false, you get NULL (which is often considered same as false).

some implementations carry the same "uncomparable" logic when checking for unique constraints, while others drop the ball here.

programming language wise, it's kinda like null pointer or float NaN, both of which are also occasionally complained about, eg. indexing maps by float values can do bogus things in case of NaNs.

edit: clarified some things




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

Search: