我的问题是:如何创建一个等效于以下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 回答
好像你无法用inSet编译 .
请参阅此处的说明:https://groups.google.com/forum/#!msg/scalaquery/2d_r4DEthfY/QqhtrR9mJdcJ