【问题标题】:Slick timestamp calculation光滑的时间戳计算
【发布时间】:2017-07-28 15:38:43
【问题描述】:

我正在为 postgres 使用 pg-slick 扩展。我尝试在 where 子句中进行计算,但我没有得到它的工作。它总是说:

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

过滤子句:

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

lastActivity 在哪里:

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

而我的 postgres 驱动程序是:

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

【问题讨论】:

    标签: slick slick-pg


    【解决方案1】:

    添加:

    val plainAPI = new API
        with Date2DateTimePlainImplicits {}
    

    似乎解决了这个问题。另外不要忘记添加with DateTimeImplicitswith PgDateSupport

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-04
      • 1970-01-01
      • 2015-01-26
      • 2015-08-06
      • 2022-01-16
      • 2017-12-07
      • 2014-08-10
      • 1970-01-01
      相关资源
      最近更新 更多