简体   繁体   中英

Missing implicit TypedType[JsonString] with slick-pg

I am using slick-pg 0.8.2 with Slick 2.1.0 and am having problems with a JSON-typed column.

My Driver is defined as follows:

trait PgsqlDriver extends PostgresDriver
                          with PgJsonSupport
                          with array.PgArrayJdbcTypes
                          with PgDateSupportJoda
                          with PgSearchSupport {
  override val pgjson = "jsonb"

  override lazy val Implicit = new ImplicitsPlus { }
  override val simple = new SimpleQLPlus {}

  trait ImplicitsPlus extends Implicits
                              with DateTimeImplicits
                              with JsonImplicits
                              with SearchImplicits

  trait SimpleQLPlus extends SimpleQL
                             with ImplicitsPlus
                             with SearchAssistants
}

object PgsqlDriver extends PostgresDriver

This is my Table class (it's abstract since I have several tables with the same structure and I subclass from this one):

private[ pgsql ] abstract class PgsqlTable[ D <: DomainObject[ D ] ](tag: Tag, tableName: String)
    extends Table[ JsonBean ](tag, tableName) {
  import PgsqlDriver.simple._

  def id = column[ String ]("ID", O.PrimaryKey)
  def json = column[ JsonString ]("JSON", O.NotNull)

  override def * = (id, json) <> (JsonBean.tupled, JsonBean.unapply)
}

As far as I can see, this is all according to the tests, examples and the docs on the slick-pg site. However, I'm getting the following compilation error on the def json = line:

Error:(23, 34) could not find implicit value for parameter tm:     scala.slick.ast.TypedType[com.github.tminglei.slickpg.JsonString]
  def json = column[ JsonString ]("JSON", O.NotNull)
                             ^

Got it! My problem was in the last line, object PgsqlDriver extends PostgresDriver instead of extends PgsqlDriver .

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