首页 文章

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

提问于
浏览
1

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

select * from table where word in ('word1', 'word2', 'word3')

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

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

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

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

1 回答

相关问题