[英]Missing implicit TypedType[JsonString] with slick-pg
我在Slick 2.1.0中使用slick-pg 0.8.2,並且在JSON類型的列上遇到問題。
我的驅動程序定義如下:
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
這是我的Table類(這是抽象的,因為我有幾個結構相同的表,並且我從這個表中繼承了子類):
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)
^
得到它了! 我的問題是在最后一行, object PgsqlDriver extends PostgresDriver
而不是extends PgsqlDriver
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.