1

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)
                             ^
cvogt
  • 11,260
  • 30
  • 46
Mario Camou
  • 2,303
  • 16
  • 28
  • possibly related issue on github: https://github.com/tminglei/slick-pg/issues/104 – Ben Reich Apr 19 '15 at 22:20
  • are you sure you're importing the correct `JsonImplicits` -- not the one from `Play` or `Json4s` or others? – Ben Reich Apr 19 '15 at 22:27
  • @BenReich: I tried the solution in the possibly related issue, but no go. According to IntelliJ, the `JsonImplicits` I'm importing are from `PgJsonSupport`, so it seems they are the right ones. I also tried using `PgJson4sSupport` and using `JValue` instead of `JsonString`, but got the same problem. – Mario Camou Apr 20 '15 at 20:57
  • Got it! My problem was in the last line, `object PgsqlDriver extends PostgresDriver` instead of `extends PgsqlDriver`. D'oh! – Mario Camou Apr 20 '15 at 21:01
  • Ah yes I see. Well you should answer your own question since you resolved it! – Ben Reich Apr 20 '15 at 21:35

1 Answers1

0

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

Mario Camou
  • 2,303
  • 16
  • 28