So e.g. I create the table vacations in postgres:
create table if not exists vacations (
person text primary key,
vacations tstzmultirange not null
)
And on the Scala side, I have:
case class Interval(start: Instant, end: Instant)
case class PersonalLeaves(person: String, onLeave: Seq[Interval])
PostgreSQL has a Data Type named Range
and one of the built-in range types is
Doobie has an extension for PostgreSQL that offer support for
uuid,inetandhstoreThere is an open issue to add support for Range type that was open on
Jul 4, 2019and the last activity was onJul 29, 2019.If you look at the unit test of postgres module for postgres types named TypeSuite, you will see the following lines where all range types are not being checked:
In this case, I think you will need to use the Custom Mappings that doobie has. I was able to find a
gistthat creates a custom mapping for tsrange which is pretty close to what you need. Also in the open issue mentioned before, there is a suggestion about how custom mapping for ranges can be done.