Avoid the trap of using where('x', '=',null)
instead of where('x', 'is',null)
#1333
Labels
where('x', '=',null)
instead of where('x', 'is',null)
#1333
Today, I ran into a problem of a query not behaving as I expected. After researching a bit, I found a stackoverflow question, which pointed me to https://en.wikipedia.org/wiki/Null_%28SQL%29#Effect_of_Unknown_in_WHERE_clauses, which got summarized by someone on that question as:
There are multiple articles about it, and since this library is about types, I'd like it to help me avoiding this error by not allowing null when using
=
or!=
or any other operator which isn't about types.My proposal would be to split up
COMPARISON_OPERATORS
insrc/operation-node/operator-node.ts
and make it a combination ofCOMPARISON_OPERATORS_NULL_SAFE
andCOMPARISON_OPERATORS_NOT_NULL_SAFE
.I know, that having
WHERE foo = null
is valid SQL, but it's a known source of error, because this will most likely not evaluate as you'd expect it.If you see this as a valuable contribution, I can create a PR.
The text was updated successfully, but these errors were encountered: