无法使用Slick-pg在Postgis上运行Slick查询

问题描述

在我的项目中,必须将位置数据保存在表上,因此我创建了以下表

create table if not exists public.person(
  email varchar(255) not null primary key,name varchar(255) not null,surname varchar(255) not null,location point
)

连同相关实体/表格:

case class Person(email: String,name: String,surname: String,location: Point)
class People(tag: Tag) extends Table[Person](tag,"person") {

  def email: Rep[String] = column[String]("email")
  def name: Rep[String] = column[String]("name")
  def surname: Rep[String] = column[String]("surname")
  def location: Rep[Point] = column[Point]("location")

  def pk = primaryKey("pk",email)

  def * : ProvenShape[Person] =
    (email,name,surname,location) <> (Person.tupled,Person.unapply)

}

然后我按照此处指定的方式创建了扩展个人资料:

trait ExtendedProfile
    extends ExPostgresProfile
    with PgDateSupport
    with PgDate2Support
    with PgPostGISSupport {

  override val api: API = new API {}

  trait API
      extends super.API
      with SimpleDateTimeImplicits
      with DateTimeImplicits
      with PostGISImplicits
      with PostGISAssistants

  val plainAPI = new API
    with ByteaPlainImplicits
    with Date2DateTimePlainImplicits
    with PostGISPlainImplicits {}
}

object ExtendedProfile extends ExtendedProfile

每当我尝试在数据库中插入一个人时,都会出现以下错误:org.postgresql.util.PSQLException: ERROR: column \"location\" is of type point but expression is of type bytea

我错过了什么吗?这是我第一次使用postgis,但是如果直接查询数据库,我可以插入点数据。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)