我只是想检查是否存在符合特定条件的行:
// Method defined on type T
def exists(some_data : Long, other_data : Long) : Boolean = DB.withSession { implicit session : Session =>
(for {
row <- table // table is a Table[T]
if row.some_data =!= some_data
if row.other_data === other_data
} yield row).length > 0
}
我收到此错误:
polymorphic expression cannot be instantiated to expected type;
[error] found : [R]scala.slick.lifted.Column[R]
[error] required: Boolean
知道发生了什么事吗?现在我只是将结果转换为scala列表(而不是.length
我有.list.length
)并检查其长度,但我不应该这样做。我在列上找不到任何方法来帮助我提取值。
答案 0 :(得分:3)
使用:.length.run
.length
returns a Column[Int],当您致电implictly converted to an Executor时the method .run