efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Support more bitwise operators

Open roji opened this issue 6 years ago • 4 comments
trafficstars

Following #18788, we can add support for xor, shift-left, shift-right etc. which seem to be pretty universally supported across databases.

roji avatar Nov 07 '19 10:11 roji

@roji This has had closed-fixed for a while without being closed.

ajcvickers avatar Mar 11 '20 16:03 ajcvickers

PR never got merged or updated.

smitpatel avatar Mar 13 '20 19:03 smitpatel

As of 7e313ab6cff18ef5c58bec565fa7da7ca6bba36f XOR is supported.

I can try and rebase https://github.com/dotnet/efcore/compare/main...roji:efcore:MoreBitwise to also tackle left and right shift if it makes sense, but I would need some guidance around the mismatches between C# and SQL:

  • C# masks the count operand to the number of bits of the operations (see docs); SQL providers have different behaviors (for example SqlServer shifts according to the sign of the count)
  • C# performs a "logical" right shift on unsigned types and an "arithmetic" right shift on signed types; some providers might not support them (AFAICT SqlServer only supports the logical shift, even though it performs it on signed values)

Note that while I have short-term plans to use the XOR (to improve some NOT translations in SqlServer), I have no immediate plan to proceed on this issue 😇

ranma42 avatar Jun 24 '24 17:06 ranma42

@ranma42 yeah, we've seen zero user interest in this, so I'd just leave it alone until we do :)

roji avatar Jun 24 '24 20:06 roji