I'm really hoping someone can help me with this. I have timestamps in Postgres stored as timestamp without timezone and need to treat them as UTC. I don't really care if I make the column type Timestamp or Instant or Long or TimestampUTC extends AnyVal except that I haven't been able to figure out how to add <= to queries when I use custom types.
But one way or another I will need access to the ResultSet so I can call getTimestamp passing in a Calendar.
I've resorted to trying to implement ColumnType[Instant] by piecing together all the needed pieces by looking at JdbcTypesComponent and slick-pg.
implicit val utcInstantMapping = new ColumnType[Instant] {
...
def getValue(r: java.sql.ResultSet, idx: Int): java.time.Instant = {
val ts = r.getTimestamp(idx, utcCalendar)
val result = Instant.ofEpochMilli(ts.getTime)
result
}
}
The getValue method got called for a column designated as Instant. But as I mentioned, I can't figure out how to get the query support for inequalities.
So I thought maybe I could just "override" the mapping for Timestamp, but how does one do that?
Any pointers would be much appreciated.