0

I'm using slick-pg to have access to types like the Point. But after following the example on the github page usage section, I still couldn't get access types like the Point class.

Here's what I have

CustomPostgresDriver.scala

package app.utils

import slick.driver.PostgresDriver
import com.github.tminglei.slickpg._

trait CustomPostgresDriver extends PostgresDriver
with PgArraySupport
with PgDateSupport
with PgRangeSupport
with PgHStoreSupport
with PgPlayJsonSupport
with PgSearchSupport
with PgPostGISSupport {
  override val pgjson = "jsonb" //to keep back compatibility, pgjson's value was "json" by default

  override lazy val Implicit = new ImplicitsPlus {}
  override val simple = new SimpleQLPlus {}

  //////
  trait ImplicitsPlus extends Implicits
  with ArrayImplicits
  with DateTimeImplicits
  with RangeImplicits
  with HStoreImplicits
  with JsonImplicits
  with SearchImplicits
  with PostGISImplicits

  trait SimpleQLPlus extends SimpleQL
  with ImplicitsPlus
  with SearchAssistants
  with PostGISAssistants
}

object CustomPostgresDriver extends CustomPostgresDriver

Users.scala

package app.models

import app.utils.CustomPostgresDriver.simple._

case class User(
    id              : Long,
    firstName       : String,
    lastName        : String,
    phone           : String,
    lat             : Point,
    long            : Point,
    updatedAt       : Timestamp,
    createdAt       : Timestamp,
)

class Users(tag: Tag) extends Table[User](tag, "USERS") {
    def id        = column[Long]("USER_ID", O.PrimaryKey, O.AutoInc)
    def firstName = column[String]("FIRST_NAME", O.NotNull)
    def lastName  = column[String]("LAST_NAME", O.NotNull)
    def phone     = column[String]("PHONE_NUMBER", O.NotNull)
    def lat       = column[Point]("LATITUDE", O.NotNull)
    def long      = column[Point]("LONGITUDE", O.NotNull)
    def updatedAt = column[Timestamp]("UPDATED_AT")
    def createdAt = column[Timestamp]("CREATED_AT")
    def *         = (id.?, firstName, lastName, phone, lat, long, updatedAt, createdAt) <> (User.tupled, User.unapply)
}

val users = TableQuery[Users]

But Point can't be found, and the suggestions intellij gives me for Timestamp is java.sql.Timestamp

I'm I doing something wrong? This have blocked me for several days now, and any help would be greatly appreciated. Thanks all

SamAko
  • 3,485
  • 7
  • 41
  • 77
  • why have both lat+long be a Point? A Point has an x,y and thus can represent your lat/lon in 1 column – gvd May 28 '15 at 06:05
  • good point, I'll look into that – SamAko May 28 '15 at 12:19
  • Are you using PostGIS or just the standard postgresql geometry types (http://www.postgresql.org/docs/9.4/static/datatype-geometric.html)? I'm not sure if pg-slick supports those (I tried searching their git repo and only found postgis types). – gvd May 28 '15 at 17:13
  • I'm working with PostGIS – SamAko May 30 '15 at 13:28

1 Answers1

0

Your codes can't be found obvious problem, pls provide more details.

But you'd better file an issue in github slick-pg, because I can't always successfully access stackoverflow, which was often blocked in our country.

tminglei
  • 53
  • 1
  • 4