Current KDocs are misleading for the actual behavior of Op.TRUE and Op.FALSE as they make it seem like the objects simply translate to the SQL types for true and false.
This is technically correct for databases that support conventional boolean data types, so the objects can be used either as a stand-alone operator or as the left- or right-hand side of any comparison operator.
But for SQL Server and Oracle, which do not support syntax like WHERE 1 or WHERE TRUE, the object's logic returns an operator that always evaluates to a boolean, like 1 = 1. So attempting to use these objects as the left- or right-hand side of any comparison operator will cause a syntax error. booleanLiteral() or booleanParam() should be used in these situations.
Current KDocs are misleading for the actual behavior of
Op.TRUE
andOp.FALSE
as they make it seem like the objects simply translate to the SQL types fortrue
andfalse
.This is technically correct for databases that support conventional boolean data types, so the objects can be used either as a stand-alone operator or as the left- or right-hand side of any comparison operator.
But for SQL Server and Oracle, which do not support syntax like
WHERE 1
orWHERE TRUE
, the object's logic returns an operator that always evaluates to a boolean, like1 = 1
. So attempting to use these objects as the left- or right-hand side of any comparison operator will cause a syntax error.booleanLiteral()
orbooleanParam()
should be used in these situations.