在我的项目中,我有必要将位置数据保存在表格中,因此我创建了下表
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,但是如果我直接查询数据库我可以插入点数据就好了。