rom-sql: PG range does not work on create
It seems that pg_range extension does not work on inserting records to the database.
rom.relations.pg_ranges.changeset(:create, range: Date.today..(Date.today + 10)).commit
/home/cutalion/.rvm/gems/ruby-2.4.1/gems/rom-sql-2.4.0/lib/rom/sql/extensions/postgres/types/range.rb:80:in `block (2 levels) in range': undefined method `exclude_begin?' for #<Range:0x0000000220da30> (NoMethodError)
Did you mean? exclude_end?
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 17 (5 by maintainers)
@culation Thank you for opened issue! I’ll explore it tomorrow in details. Now I see that
overlapseems like broken, I would like to fix it.@cutalion this is a common practice for DB adapters to coerce input data to expected data types.
rom-sqlusually don’t do anything with your data and relies on the coercion provided by the underlying stack (Sequel + DB adapter). At the same time, we don’t want to expose implementation details by returning Sequel’s wrapper types so we have to provide our own, that’s why we need a custom input type constructor which doesn’t work with::Rangeat the moment. This can and should be improved.However, since PG ranges cannot be represented as
::Rangeinstances in general, we cannot return them. If you’re sure you don’t have such cases where::Rangecan’t work you can roll your own type, just in the same way it’s done forROM::SQL::Postgres::Range. Our best approach is to provide a non-safeto_rangeconverter forROM::SQL::Postgres::Values::Range