[英]inferred type arguments [Boolean] do not conform to method filter's type parameter bounds [T <: slick.lifted.Rep[_]]
I got compile error on the following for the type Boolean, but it works fine for other data types. 对于以下类型的布尔值,我在以下发生了编译错误,但对于其他数据类型则正常。 Any ideas?
有任何想法吗? Please advise.
请指教。 Thanks
谢谢
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
Here's the code: 这是代码:
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)))
}
If you look at the QUERIES documentation you might find the following warning 如果查看QUERIES文档 ,可能会发现以下警告
Most operators mimic the plain Scala equivalents, but you have to use
===
instead of==
for comparing two values for equality and=!=
instead of!=
for inequality.大多数运算符都模仿普通的Scala等价物,但是您必须使用
===
而不是==
来比较两个值是否相等,而要用=!=
而不是!=
来比较不平等。 This is necessary because these operators are already defined (with unsuitable types and semantics) on the base type Any, so they cannot be replaced by extension methods.这是必需的,因为这些运算符已经在基本类型Any上定义了(具有不合适的类型和语义),因此它们不能用扩展方法代替。
So change your code to use ===
as following: 因此,将您的代码更改为使用
===
,如下所示:
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)))
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.