perotom
perotom

Reputation: 923

Slick timestamp calculation

I am using the pg-slick extension for postgres. I try to do a calculation in the where clause but i don't get it working. It always says:

value - is not a member of java.sql.Timestamp

Filter clause:

 .filter(r => Timestamp.from(Instant.now()) - r.lastActivity < Duration.ofMinutes(30))

where lastActivity is:

def lastActivity = column[Timestamp]("last_activity")

and my postgres driver is:

trait MyPostgresDriver extends ExPostgresProfile
  with PgPostGISSupport
  with PgDate2Support
  with PgEnumSupport {

  override val api: API = new API {}

  ///
  trait API extends super.API
    with PostGISImplicits
    with DateTimeImplicits
    with PostGISAssistants {
  }
}
object MyPostgresDriver extends MyPostgresDriver

Upvotes: 0

Views: 211

Answers (1)

perotom
perotom

Reputation: 923

Adding:

val plainAPI = new API
    with Date2DateTimePlainImplicits {}

seems to solve the issue. Also don't forget to add with DateTimeImplicits and with PgDateSupport

Upvotes: 0

Related Questions