News for hackers. Stuff that matters.
Re:SQL NULLs Are Weird by thayne on Thursday January 09, 2025 @11:07PM (#42652344)
If only it had a name that was more indicative of that, like UNKNOWN, or UNDEFINED or INDERTIMINATE or something.
Re:SQL NULLs Are Weird by dominicrose on Friday January 10, 2025 @04:14AM (#42654005)
Javascript has both null and undefined and I'm not sure that's a good idea. At least in SQL we only have one of them, but it can mean unknown or it can mean N/A or even false. It's like a joker, what it means depends on how you use it.
Re:SQL NULLs Are Weird by hun3 on Friday January 10, 2025 @05:36AM (#42654464)
Or VBA, which has Empty, Null, and Nothing:

https://excelbaby.com/learn/the-difference-between-empty-nul...

(and sometimes Missing)

Re:SQL NULLs Are Weird by hobs on Friday January 10, 2025 @08:29AM (#42655428)
No, it's not those other things, that's just using the tool incorrectly. A NULL is definitely "we dont know", not false, not N/A, especially not any known value.
Re:SQL NULLs Are Weird by swiftcoder on Friday January 10, 2025 @09:39AM (#42655922)
Except in every other programming language with a null, null is the definite absence of something
Re:SQL NULLs Are Weird by hobs on Friday January 10, 2025 @05:09PM (#42660834)
Sure, and we're talking about SQL nulls in this context, which is why I am strict in my definition.
Re:SQL NULLs Are Weird by dominicrose on Monday January 13, 2025 @04:19AM (#42681566)
Yes and I think that Clojure handles nil pretty well, and it's a functional programming language like SQL. It's also interesting to see that Typescript has added an unknown type. So something that's a value in SQL (null being unknown) is a type in TS.
Re:SQL NULLs Are Weird by salawat on Friday January 10, 2025 @04:27AM (#42654079)
Null is shorter, and given the nightmarish queries I've had to read/write, I'll take any mercy that comes my way.
Re:SQL NULLs Are Weird by Pxtl on Friday January 10, 2025 @10:24AM (#42656422)
Honestly, at this point I just wish SQL servers supported proper discriminated union types and nullable columns were implemented as some kind of MaybeKnown<T> and I could just have a normal Maybe<T> with normal equality semantics if I wanted.

SQL needs to join 21st century type systems... or needs to get replaced altogether. SQL is the FORTRAN of relational programming languages, but hangs around because every time somebody tries to replace it they throw the relational-theory baby out with the bath-water.

Re:SQL NULLs Are Weird by johnthescott on Saturday January 11, 2025 @01:48AM (#42663850)
> SQL is the FORTRAN of relational programming languages

and what is an alternative to sql ... quel?

Re:SQL NULLs Are Weird by atombender on Saturday January 11, 2025 @06:39AM (#42665211)
E. F. Codd originally suggested two types of values: "unknown" and "missing". Somehow we got NULL, which represents both.

ANSI SQL:1991 provides an optional feature that introduces a special value UNKNOWN to boolean expressions [1]. But few databases support it. MSSQL [2] is one of the few that do. As I understand it, it's not a data type that be used in tables, but is only a potential result of boolean operations.

[1] https://modern-sql.com/concept/three-valued-logic

[2] https://learn.microsoft.com/en-us/sql/t-sql/language-element...