简体   繁体   中英

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

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] :

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. 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) :

Changing from CHAR(1) to VARCHAR(3) and re running the code generator solved the issue from:

 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM