如何在使用 Phantom DSL 为 ScyllaDB 的 `where` 子句中使用 `or`?

huangapple go评论52阅读模式
英文:

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

SelectQuerywhere方法会再次返回一个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.

huangapple
  • 本文由 发表于 2023年6月15日 16:34:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480617.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定