Currently if you create record that contains a value which is Values::Range
of type tsrange
then you lose the micro second precision on the lower and upper values.
This is because the object is being serialised into a string rom-sql/range.rb at master · rom-rb/rom-sql · GitHub
def self.range(name, read_type)
Type(name) do
type = SQL::Types.Nominal(Values::Range).constructor do |range|
format("%s%s,%s%s",
range.exclude_begin? ? :'(' : :'[',
range.lower,
range.upper,
range.exclude_end? ? :')' : :']')
end
type.meta(read: read_type)
end
end
This can be solved by casting the range object to a Sequel::Postgres::PGRange
instead e.g.
def self.range(name, read_type)
Type(name) do
type = SQL::Types.Nominal(Values::Range).constructor do |range|
Sequel::Postgres::PGRange.new(range.lower, range.upper, exclude_begin: range.exclude_begin?, exclude_end: range.exclude_end?)
end
type.meta(read: read_type)
end
end
Or is there good reason we do not take this approach?