vapor/sql-kit

SQL bitwise operators: &, |, ^...

tarag opened this issue · 2 comments

tarag commented

Since SQL bitwise operators are not supported, one must use raw SQL syntax for queries using these operators.

It would be great if we could do :

MyModel.query(on: app.db)
            .filter(\.$optionSet & myOption)

instead of

MyModel.query(on: app.db)
            .filter(.sql(raw: "(option_set & \(myOption) != 0"))
0xTim commented

You could write this as

MyModel.query(on: app.db)
            .filter(\.$optionSet, .custom("&"), myOption)

Additionally, this issue should be on fluent-kit, not sql-kit.