我的代码:
def function1(userId: Long) = DB withConnection {
implicit con =>
val res = SQL(
"""
SELECT my_custom_function({userId}, {param2}) as "my_title"
"""
).on('userId -> userId,
'param2 -> Array(Statuses.paid.id, Statuses.pending.id))
.as(SqlParser.get[Option[Long]]("my_title").single) //error
if (res.isDefined) res.get
else 0L
}
my_custom_function
返回Long
或BigInt
。
此代码抛出错误[PSQLException: Can't infer the SQL type to use for an instance of [I. Use setObject() with an explicit Types value to specify the type to use.]
这是怎么回事?
答案 0 :(得分:0)
我认为问题是数组参数。最新的Anorm防止可能导致此类情况的不安全参数转换。您可以使用Anorm快照进行尝试。