select
*,
"a.$number"="b.$number",
"a.$number" is null,
"b.$number" is null,
("a.$number" is null and "b.$number" is null) AS both_null
from
testing
I did this because the database was returning the wrong rows. The logic looked good, but where did it go wrong. All declarative languages are like this: They are wonderful to read, maybe a delight to write, but if your declaration is wrong, you will spend a long time figuring out why. SQL is not pure declarative, more functional, so it is not impossible to debug, but still harder than stepping through with your debugger.
I listed all the intermediate logic steps over all records to verify each step.
Found the problem you are dealing with:
While running
test_ne
in TestSetOps, try this:I did this because the database was returning the wrong rows. The logic looked good, but where did it go wrong. All declarative languages are like this: They are wonderful to read, maybe a delight to write, but if your declaration is wrong, you will spend a long time figuring out why. SQL is not pure declarative, more functional, so it is not impossible to debug, but still harder than stepping through with your debugger.
I listed all the intermediate logic steps over all records to verify each step.
Notice the
null
s!1=null
returns anull
, notfalse
. There fornot(1=null)
also returnsnull
, which is "falsey" in thewhere
clause.First
eq
is not returning the correct values; it should not be returningnull
at all.