英文:
How to use 'or' with 'where' clause for scylladb using phantom dsl?
问题
我正在使用Phantom DSL库执行ScyllaDB操作。现在我尝试将'where'子句与'or'子句结合起来,但它不起作用。
db.object
.select
.where(_.businessEmail eqs "abc@gmail.com")
.or(_.homeEmail eqs "abc@gmail.com")
.or(_.additionalEmail eqs "abc@gmail.com")
.fetch()
错误:
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]
可能的原因:`value or`之前可能缺少分号?
.or(_.homeEmail eqs "abc@gmail.com")
如何使用'or'子句?
英文:
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 "abc@gmail.com")
.or(_.homeEmail eqs "abc@gmail.com")
.or(_.additionalEmail eqs "abc@gmail.com")
.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 "abc@gmail.com")
How can I use 'or' clause?
答案1
得分: 1
SelectQuery
的where方法会再次返回一个SelectQuery
,允许您调用and方法,该方法将被翻译为WHERE
子句中的AND
运算符。如果您查看SelectQuery
的方法,您将发现其中没有任何方法允许在WHERE
子句中使用OR
运算符,因为ScyllaDB支持OR运算符。
在ScyllaDB的官方文档中,您还会看到select语句没有OR
运算符,对于CQL中的select语句也是如此。
在ScyllaDB的存储库中有一个开放的问题,要求在CQL中添加基本支持逻辑OR运算符。不确定这是否会添加到phantom,因为最后一次提交是在2021年8月16日。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论