ktorm icon indicating copy to clipboard operation
ktorm copied to clipboard

add bitAnd and bitOr BinaryExpressionType and operator

Open KunMinX opened this issue 1 year ago • 2 comments

so we can build bitAnd sql like follow:

SELECT * 
FROM Note 
WHERE ((Note.feature & ?) = ?) 

KunMinX avatar Aug 03 '24 02:08 KunMinX

Thanks for your PR. It's OK to have bitwise operation support in Ktorm, but I have 2 suggestions:

  1. Bitwise operation is not part of standard SQL, different dialects have different operators, so the code should be in ktorm-support-mysql module instead of ktorm-core.
  2. It would be better to keep the operator function names consistent with Kotlin's built-in bitwise operator functions, like and, or, xor, shl, shr, inv.

vincentlauvlwj avatar Aug 09 '24 03:08 vincentlauvlwj

Thank you for your suggestions.

Bitwise operations allow for the aggregation of several states into one field, which helps to avoid frequent database upgrades in the event of future business changes.

This time around, during the development of KMP, I was introduced to Ktorm. Combining your suggestions above, I believe Ktorm has a well-planned design.

I will just throw a brick to attract jade and will not continue with PR for the time being.

It is worth mentioning that its documentation is user-friendly, and I have read through it completely.

KunMinX avatar Aug 10 '24 16:08 KunMinX