[英]Slick 3.0.3 error: could not find implicit value for parameter rconv
I have the model as Tables.scala
generated with Slick 3.0.3 that includes the GetResult implicit conversion from a result set for all my model classes eg 我有一个由Slick 3.0.3生成的
Tables.scala
模型,其中包括来自我所有模型类的结果集的GetResult隐式转换
implicit def GetResultInstrumentRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[String]], e3: GR[Char], e4: GR[Option[Int]]): GR[InstrumentRow] = GR{
prs => import prs._
InstrumentRow.tupled((<<[Int], <<[String], <<?[String], <<[Char], <<?[Int], <<?[Int], <<[Int]))
}
but still the following code produces error could not find implicit value for parameter rconv: slick.jdbc.GetResult[models.Tables.InstrumentRow]
: 但是以下代码仍然产生错误
could not find implicit value for parameter rconv: slick.jdbc.GetResult[models.Tables.InstrumentRow]
:
import play.api.db.DB
import slick.driver.PostgresDriver.backend.Database._
import slick.jdbc.{StaticQuery => Q}
import play.api.Play.current
import models.Tables._
class InstrumentDao {
/**
* Returns all available instruments.
*
* @return all available instruments.
*/
def findInstruments() : List[InstrumentRow] = DB.withConnection() { implicit conn =>
Q.queryNA[InstrumentRow](s"""select * from "${Instrument.baseTableRow.tableName}"""").list
}
}
Oh found the problem, it wasn't related to the code on the OP, that code is correct and works as it should. 哦,发现了问题,它与OP上的代码无关,该代码正确无误,并且可以正常工作。 The issue was on the code generator/and the implicit implementation namely it didn't like an attribute of type
Char
ie on the Postgres database CHAR(1)
: 问题出在代码生成器/和隐式实现上,即它不喜欢
Char
类型的属性,即在Postgres数据库CHAR(1)
:
Changing from CHAR(1)
to VARCHAR(3)
and re running the code generator solved the issue from: 从
CHAR(1)
更改为VARCHAR(3)
并重新运行代码生成器解决了以下问题:
case class InstrumentRow(id: Int, `type`: Char)
implicit def GetResultInstrumentRow(implicit e0: GR[Int], e1: GR[Char]): GR[InstrumentRow] = GR{
prs => import prs._
InstrumentRow.tupled((<<[Int], <<[Char]))
}
to 至
case class InstrumentRow(id: Int, `type`: String)
implicit def GetResultInstrumentRow(implicit e0: GR[Int], e1: GR[String]): GR[InstrumentRow] = GR{
prs => import prs._
InstrumentRow.tupled((<<[Int], <<[String]))
}
It seems like a bug in the implicit conversion and/or the generator. 似乎是隐式转换和/或生成器中的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.