我有一个由PostgreSQL支持的原始查询。我想运行这样的查询:var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', url);
ourRequest.onload = function() {
var ourData = JSON.parse(ourRequest.responseText);
renderHTML(ourData);
};
ourRequest.send();
。请注意,操作是select something from my_table where action in (1,2,3)
integer
字段
我的以下方法出现编译错误:
找不到参数e的隐式值: slick.jdbc.SetParameter [List [Int]]
my_table
问题
如何显式设置def myMethod(actions: List[Int]]) {
sql"""select something from my_table
where action in (${actions})""".as[MyType]
}
参数,以便我可以成功运行List[Int]
查询?
答案 0 :(得分:0)
尝试
def myMethod(actions: List[Int]) =
sql"""select something from my_table
where action in #${actions.mkString("(", ",", ")")}""".as[MyType]
http://slick.lightbend.com/doc/3.3.0/sql.html#splicing-literal-values
答案 1 :(得分:0)
使用他的slick-postgreSQL扩展: https://github.com/tminglei/slick-pg
更多信息: How to pass an array to a slick SQL plain query?
implicit val setIntArray: SetParameter[Array[Int]] = mkArraySetParameter[Int](...)