-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Server: support bitwise NOT on boolean values #34213
Comments
Just noting that bitwise NOT is useful also for non-boolean types, so this would be useful beyond the specific SQL Server scenario we've been focusing on (and beyond SQL Server in general). |
Non-boolean types can already use the bitwise not: efcore/src/EFCore.Relational/Query/QuerySqlGenerator.cs Lines 883 to 885 in 73db4f0
The boolean case is explicitly treated as special: efcore/src/EFCore.Relational/Query/QuerySqlGenerator.cs Lines 856 to 874 in 73db4f0
The current encoding does not differentiate between bitwise and logical not (well, on boolean expressions it is always the logical not, on integer expressions it is always the bitwise not). |
I am thinking about working on this. My approach would be to extend |
For boolean expressions, bitwise
~
and logicalNOT
are generally the same, but in SqlServer the first can be applied onBIT
s, while the second one is for boolean predicates.Since #34080 the SqlServer provider avoids converting to a predicate when it just needs to negate a
BIT
, but it does so using^ 1
.A better translation could be emitted by translating to a
~
.The text was updated successfully, but these errors were encountered: