我尝试根据示例添加列[slick-pg示例] [1]
还添加到类表含义
implicit val pointFormat = MyFormats.geometryFormat[Point]
但有编译错误
could not find implicit value for parameter tt: slick.ast.TypedType[com.vividsolutions.jts.geom.Point]
我做错了什么?你能举个例子吗? ^
BR!
答案 0 :(得分:0)
在this指令之后编写与PostgresDriver的集成时,在覆盖with PostGISImplicits
的对象中添加api
(此特征未包含在示例中)。
答案 1 :(得分:0)
我为我工作的是以下设置:
首先,我的表声明:
class EventTable(tag: Tag) extends Table[Event](tag, "event"){
def uid = column[String]("uid", O.PrimaryKey, O.Length(36))
def userUid = column[String]("user_uid")
def location = column[Point]("location")
def start = column[LocalDateTime]("start")
def end = column[LocalDateTime]("end")
def visible = column[Boolean]("visible")
def attending = column[Int]("attending")
def required = column[Int]("required")
def createdAt = column[LocalDateTime]("created_at")
def * = (uid, userUid, location, start, end, visible, attending, required, createdAt) <>
(Event.tupled, Event.unapply)
}
我需要扩展:java8时间支持(LocalDateTime)和geo stuff(Point)。这反映在我的build.sbt
- 我使用版本0.11.0 for slick-pg:
"com.github.tminglei" %% "slick-pg" % slickPgV,
"com.github.tminglei" %% "slick-pg_jts" % slickPgV,
"com.github.tminglei" %% "slick-pg_date2" % slickPgV,
现在,驱动程序声明:
import com.github.tminglei.slickpg._
trait ExtendedPostgresDriver extends ExPostgresDriver
with PgArraySupport
with PgDate2Support
with PgRangeSupport
with PgHStoreSupport
with PgSearchSupport
with PgPostGISSupport
with PgNetSupport
with PgLTreeSupport {
override val api = MyAPI
object MyAPI extends API with ArrayImplicits
with DateTimeImplicits
with PostGISImplicits
with NetImplicits
with LTreeImplicits
with RangeImplicits
with HStoreImplicits
with SearchImplicits
with SearchAssistants {
implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList)
}
}
object ExtendedPostgresDriver extends ExtendedPostgresDriver
所以,拿java 8时间的东西。您可以注意到驱动程序使用PgDate2Support
,然后允许我使用隐式DateTimeImplicits
。通过在我感兴趣的类中导入ExtendedPostgresDriver.api._
,我可以让表定义使用我需要的LocalDateTime
类型。
Point
同样如此:PgPostGISSupport
- &gt; PostGISImplicits
- &gt; Point
。
希望这有帮助