我正在将SQL查询转换为光滑的DSL。我陷入了时间戳转换。 我的SQL查询是:
Select isActive from users where create_time <= TIMESTAMPADD(MINUTE,
${AUTO_EXPIRY_DB_DAYS * HOURS_24 * MINUTES_60}, sysdate())
and isVerified=false;
如何编写一个相同的查询?
userQuery.filter(user => user.isVerified === FALSE && user.createdDate
<= ?????).map(_.isActive)
答案 0 :(得分:0)
看看标量数据库函数slick documentation。我想这应该起作用:
val sysdate = SimpleLiteral[java.sql.Timestamp]("sysdate")
val timestampAdd = SimpleFunction.ternary[String, Int, java.sql.Timestamp, java.sql.Timestamp]("TIMESTAMPADD")
userQuery
.filter(user => user.isVerified === FALSE
&& user.createdDate <= timestampAdd("MINUTE", 20, sysdate))
.map(_.isActive)