【问题标题】:Scala Slick compiled query equivalent to "select * from table where word in (words)"Scala Slick 编译查询相当于“select * from table where word in (words)”
【发布时间】:2018-02-22 10:54:58
【问题描述】:

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

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

我目前遇到的代码如下所示:

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

编译时出现如下错误:

Set[String] => slick.lifted.Query[com.company.business.db.CensoredKeyWords,com.company.business.db.CensoredKeyWords#TableElementType,Seq] 类型的计算无法编译(作为类型 C) val findByWords = 已编译 { 字词:Set[String] => ^

注意箭头指向一个花括号。

我使用的是 Slick 3.2.1。斯卡拉 2.12.3

【问题讨论】:

    标签: scala slick


    【解决方案1】:

    你好像不能用 inSet 编译。

    请看这里的解释:https://groups.google.com/forum/#!msg/scalaquery/2d_r4DEthfY/QqhtrR9mJdcJ

    【讨论】:

      猜你喜欢
      • 2011-04-06
      • 1970-01-01
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      • 2023-01-11
      • 1970-01-01
      相关资源
      最近更新 更多