![](/img/trans.png)
[英]Scala, Play Framework Slick issue - could not find implicit value for parameter rconv
[英]Slick 3.0.3 error: could not find implicit value for parameter rconv
我有一个由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]))
}
但是以下代码仍然产生错误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
}
}
哦,发现了问题,它与OP上的代码无关,该代码正确无误,并且可以正常工作。 问题出在代码生成器/和隐式实现上,即它不喜欢Char
类型的属性,即在Postgres数据库CHAR(1)
:
从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]))
}
至
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]))
}
似乎是隐式转换和/或生成器中的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.