Joh*_*hn 2 scala playframework slick
我对以下类型的布尔值有编译错误,但它适用于其他数据类型.有任何想法吗?请指教.谢谢
inferred type arguments [Boolean] do not conform to method filter's type parameter bounds [T <: slick.lifted.Rep[_]]
[error] db.run(repo.filter(_.id == id).map(r => (r.id, r.name, r.isPublic)).update((id, name, isPublic)))
[error] type mismatch;
[error] found : proj.domain.mapping.RepositoryMapping => Boolean
[error] required: proj.domain.mapping.RepositoryMapping => T
[error] db.run(repo.filter(_.id == id).map(r => (r.id, r.name, r.isPublic)).update((id, name, isPublic)))
[error] ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
Run Code Online (Sandbox Code Playgroud)
这是代码:
def updateTest(id: Long, name: String, isPublic: Boolean): Unit = {
db.run(repo.filter(_.id == id).map(r => (r.id, r.name, r.isPublic)).update((id, name, isPublic)))
}
Run Code Online (Sandbox Code Playgroud)
Ser*_*gGr 11
如果查看QUERIES文档,您可能会发现以下警告
大多数运算符都模仿普通的Scala等价物,但您必须使用
===而不是==比较两个值来获得相等而=!=不是用于比较!=不等式.这是必要的,因为已经在基类型Any上定义了这些运算符(具有不适合的类型和语义),因此它们不能被扩展方法替换.
因此,请将您的代码更改为使用===如下:
def updateTest(id: Long, name: String, isPublic: Boolean): Unit = {
db.run(repo.filter(_.id === id).map(r => (r.id, r.name, r.isPublic)).update((id, name, isPublic)))
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
903 次 |
| 最近记录: |