efcore
efcore copied to clipboard
Use XOR to translate some == and != expressions
When the parent expression is not a predicate, translate x != y to:
x ^ y
instead of
CASE
WHEN x <> y THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END
Similarly, translate x == y to:
x ^ y ^ CAST(1 AS bit)
instead of
CASE
WHEN x == y THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END
Contributes to #34001 for simple cases (comparison of BIT expressions).
This is a continuation of #34080.
Conceptually it also reduces the number of expressions that hit #34001, but in practice (because of the null rewriting) the expressions that it affects are only those that compare non-nullable BIT expressions.
This would change if there was some optimization like #34126.
Thanks again @ranma42 !