[英]Cannot run slick queries on postgis with slick-pg
在我的項目中,我有必要將位置數據保存在表上,因此我創建了下表
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,但是如果我直接查詢數據庫,我可以插入點數據就好了。
嘗試這個
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 geometry
)
Point
不是PostGIS 類型。 slick-pg僅支持 PostGIS 類型。 PostGIS 中的所有形狀都由geometry
類型表示
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.