PGInterval => Parameter
and then instead of trying to interpolate a Long, with sql"... AGE(now(), created_at) <= interval '$long milliseonds'
you could just interpolate the full PGInterval
: sql"... AGE(now(), created_at) <= $pgInterval"
(you might need the interval
function too, I'm not sure). I haven't had a chance to test this. I will as soon as I can but feel free to give it a shot in the meantime.
implicit class PGIntervalParameter(value: PGInterval) extends SingleParameter {
protected def set(stmt: PreparedStatement, i: Int) = stmt.setObject(i, value)
}
And then you can query like this:val interval = new PGInterval(s"${sessionDuration.toMillis} milliseconds")
sql"SELECT session_id, user_uuid, device_uuid FROM sessions WHERE session_id = $sessionId AND AGE(now(), created_at) < $interval"
+
with two sql""
strings should work. Is that not working for you?
val start = new DateTime(2016, 1, 1, 0, 1, 1)
sql"select * from measurement where end_interval >= ${start.toDate} limit 10"
scala> sql"select * from measurement where end_interval >= ${start.toDate} limit 10"
res25: com.lucidchart.relate.InterpolatedQuery = select * from measurement where end_interval >= ? limit 10
delete from management where key in (?);
sql"delete from $table where key in ($deleteKeys);"
$deletedKeys
contains a string value
foo