Scala Slick编译的查询相当于"select*from table where word in in(words)"

has*_*981 1 scala slick

我的问题是:如何创建一个等效于以下SQL的Slick编译查询:

select * from table where word in ('word1', 'word2', 'word3')
Run Code Online (Sandbox Code Playgroud)

我目前坚持使用的代码如下所示:

val findByWords = Compiled { words: Set[String] =>
  keywords.filter(_.word inSet words)
}
Run Code Online (Sandbox Code Playgroud)

编译时,我收到以下错误:

Computation of type Set[String] => slick.lifted.Query[com.company.business.db.CensoredKeyWords,com.company.business.db.CensoredKeyWords#TableElementType,Seq] cannot be compiled (as type C)
val findByWords = Compiled { words: Set[String] =>
                           ^

请注意,箭头指向大括号.

我正在使用Slick 3.2.1.Scala 2.12.3

Tei*_*raz 5

好像你无法用inSet编译.

请参阅此处的说明:https://groups.google.com/forum/#! msg/scalaquery/dd_r4DEthfY/QqhtrR9mJdcJ