简体   繁体   English

推断的类型参数[Boolean]不符合方法过滤器的类型参数范围[T <:slick.lifted.Rep [_]]

[英]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.

相关问题 类型 arguments [T] 不符合方法产品的类型参数界限 [T &lt;: Product] - type arguments [T] do not conform to method product's type parameter bounds [T <: Product] WrappedArray的集合:类型参数[Int]不符合方法empty的类型参数范围[T &lt;:AnyRef] - Set of WrappedArray: Type arguments [Int] do not conform to method empty's type parameter bounds [T <: AnyRef] 类型参数不符合特征栏的类型参数范围 - type arguments do not conform to trait Bar's type parameter bounds 类型参数不符合特征Subtractable的类型参数边界 - type arguments do not conform to trait Subtractable's type parameter bounds 理解Scala中的“推断类型参数不符合类型参数边界”错误 - Understanding “inferred type arguments do not conform to type parameter bounds” errors in Scala 类型参数[List [String]]不符合方法确保的类型参数范围[AA&gt;:A] - type arguments [List[String]] do not conform to method ensure's type parameter bounds [AA >: A] Scala 类型 arguments 不符合方法 eval 的类型参数界限 - Scala type arguments do not conform to method eval's type parameter bounds Scala错误:类型参数不符合类类型参数范围 - Scala error: type arguments do not conform to class type parameter bounds Scala:类型参数不符合类类型参数范围 - Scala: type arguments do not conform to class type parameter bounds 理解Scala中的“类型参数不符合类型参数边界”错误 - Understanding “type arguments do not conform to type parameter bounds” errors in Scala
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM