0

In my project I ha ve the necessity to save location data on a table, so I created the following table

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
)

along with the relative entity / table:

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)

}

then I created my extended profile as specified here:

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

whenever I try to insert a person in the database, I get the following error: org.postgresql.util.PSQLException: ERROR: column \"location\" is of type point but expression is of type bytea

am I missing something? It's the first time I use postgis, but if I query the database directly I can insert point data just fine.

Luca
  • 1,116
  • 2
  • 15
  • 24

1 Answers1

0

Try this

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 is not PostGIS type. slick-pg supports only PostGIS type. All the shapes in PostGIS are represented by type geometry

Nitishkumar Singh
  • 1,781
  • 1
  • 15
  • 33