2015-04-19 25 views
1

我在slick 2.1.0中使用slick-pg 0.8.2,並且在使用JSON類型的列時遇到問題。Missing隱式TypedType [JsonString] with slick -pg

我的司機被定義如下:

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 

這是我的表類(它是抽象的,因爲我有相同的結構幾個表,我從這個子類):

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) 
} 

據我所知,這完全取決於slick-pg網站上的測試,示例和文檔。但是,我在def json =系列上收到以下編譯錯誤:

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) 
          ^
+0

github上的可能相關問題:https://github.com/tminglei/slick-pg/issues/104 –

+0

你確定你正在導入正確的'JsonImplicits' - 而不是'Play'或' Json4s'或其他? –

+0

@BenReich:我在可能相關的問題上嘗試瞭解決方案,但沒有去。根據IntelliJ,我輸入的'JsonImplicits'來自'PgJsonSupport',所以它看起來是正確的。我也嘗試使用'PgJson4sSupport'並使用'JValue'而不是'JsonString',但也遇到了同樣的問題。 –

回答

0

知道了!我的問題是在最後一行object PgsqlDriver extends PostgresDriver而不是extends PgsqlDriver

相關問題