|
|
|
|
|
by Pxtl
1445 days ago
|
|
> This isn't quite true - these comparisons don't evaluate to false, they evaluate to NULL. Which large parts of SQL treat as equivalent to false. WITH vars AS (
SELECT CAST(null AS INT) as X
)
SELECT 'yes this is a tautology' as "is this is a tautology"
FROM vars
WHERE X = X
The above query returns nothing, not an error because the value of X is unknowable. In a sane language, X=X and so it would yield "yes this is a tautology". SQL standard wants it both ways - it wants to say "boolean null isn't false" except when for its own convenience it decides that yes, null is false.The truth, imho, is that SQL has an archaic type system. In this day and age it should be offering algebraic types where we can implement our own "empty" values and the like that may not use three-value logic as appropriate, so that I can say that for example End Date is blank instead of either unknown or Date.MaxValue. |
|
I don't see it that way. Null cast to boolean is always false. Null equality is undefined. There is no contradiction there.