Slick 3.0.3 error: could not find implicit value for parameter rconv
Slick 3.0.3 error: could not find implicit value for parameter rconv
我的模型 Tables.scala
使用 Slick 3.0.3 生成,其中包括从我所有模型的结果集的 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 上的代码无关,该代码是正确的并且可以正常工作。问题出在代码 generator/and 隐式实现上,即它不喜欢 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]))
}
这似乎是隐式转换 and/or 生成器中的错误。
我的模型 Tables.scala
使用 Slick 3.0.3 生成,其中包括从我所有模型的结果集的 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 上的代码无关,该代码是正确的并且可以正常工作。问题出在代码 generator/and 隐式实现上,即它不喜欢 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]))
}
这似乎是隐式转换 and/or 生成器中的错误。