Allan Galarza
05/10/2022, 4:08 PMUPDATE server_premium
SET expiration = expiration + $1
WHERE server_id = $2
RETURNING expiration
Where $1 is a python timedelta, that was converted to a Postgresql Interval
I'm trying to figure out how to do it in exposed.fun Column<Instant?>.plusDuration(duration: Duration): CustomOperator<Instant> {
val intervalExpression = object : Expression<Instant>() {
override fun toQueryBuilder(queryBuilder: QueryBuilder) =
queryBuilder { +"INTERVAL '${duration.inWholeSeconds} seconds'" }
}
return CustomOperator("+", columnType, this, intervalExpression)
}
With this now I can update the value like:
it[expiration] = expiration.plusDuration(days.days)