How to use 'or' with 'where' clause for scylladb using phantom dsl?

47 Views Asked by At

I'm using phantom dsl library to perform scylladb operations. Now I was trying to combine 'where' clause with 'or' clause but its not working.

db.object
.select
.where(_.businessEmail eqs "[email protected]")
.or(_.homeEmail eqs "[email protected]")
.or(_.additionalEmail eqs "[email protected]")
.fetch()

Error:

value or is not a member of com.outworkers.phantom.builder.query.SelectQuery[com.outworkers.phantom.builder.Unlimited,com.outworkers.phantom.builder.Unordered,com.outworkers.phantom.builder.Unspecified,com.outworkers.phantom.builder.Chainned,shapeless.HNil]
possible cause: maybe a semicolon is missing before `value or`?
      .or(_.homeEmail eqs "[email protected]")

How can I use 'or' clause?

1

There are 1 best solutions below

0
Gastón Schabas On

The where method from SelectQuery returns again a SelectQuery, which allows you to invoke and method that will be translated as an AND operator in the WHERE clause. If you look at the methods of SelectQuery, you will not find any of them that lets use the OR operator in the WHERE clause because OR operator is supported in ScyllaDB.

In the official docs of ScyllaDB, you will also see that a select statement doesn't have an OR operator and the same happens for a select statement in CQL.

There is an open issue in the repo of ScyllaDB to Add basic support for the logical OR operator in CQL. Not sure if that will be added to phantom knowing that the last commit was on Aug 16, 2021.