Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG range insertion does not work with rom 5.1.1 #343

Open
cutalion opened this issue Aug 15, 2019 · 0 comments
Open

PG range insertion does not work with rom 5.1.1 #343

cutalion opened this issue Aug 15, 2019 · 0 comments
Labels

Comments

@cutalion
Copy link

Creating record in table with pg range column does not work.

Example: https://github.com/cutalion/rom_experiments/blob/fdae88c28d7f5b59ccf9a40de8a4fc0916b9c2c5/pg_range.rb

def try(name)
  yield
  puts "#{name} works"
  rescue => e
    puts "#{name} does not work"
    puts e.message
  ensure
    puts
end


ruby_range = Range.new(Time.now, Time.now)
rom_range = ROM::SQL::Postgres::Values::Range.new(Time.now, Time.now)
sequel_range = Sequel::Postgres::PGRange.new(Time.now, Time.now)
custom_range = CustomRange.new(Time.now, Time.now)

try(:ruby_range) { pg_ranges.changeset(:create, range: ruby_range).commit }
try(:sequel_range) { pg_ranges.changeset(:create, range: sequel_range).commit }
try(:rom_range) { pg_ranges.changeset(:create, range: rom_range).commit }
try(:custom_range) { pg_ranges.changeset(:create, range: custom_range).commit }

Output:

$ bundle exec ruby pg_range.rb
ruby_range does not work
2019-08-15 19:37:25 +0300..2019-08-15 19:37:25 +0300 (Range) has invalid type for :range violates constraints (undefined method `exclude_begin?' for 2019-08-15 19:37:25 +0300..2019-08-15 19:37:25 +0300:Range
Did you mean?  exclude_end? failed)

sequel_range does not work
#<Sequel::Postgres::PGRange:0x000055f59c094448 @begin=2019-08-15 19:37:25 +0300, @end=2019-08-15 19:37:25 +0300, @empty=false, @exclude_begin=false, @exclude_end=false, @db_type=nil> (Sequel::Postgres::PGRange) has invalid type for :range violates constraints (undefined method `lower' for #<Sequel::Postgres::PGRange:0x000055f59c094448> failed)

rom_range does not work
"[2019-08-15 19:37:25 +0300,2019-08-15 19:37:25 +0300)" (String) has invalid type for :range violates constraints (undefined method `exclude_begin?' for "[2019-08-15 19:37:25 +0300,2019-08-15 19:37:25 +0300)":String failed)

custom_range does not work
"[2019-08-15 19:37:25 +0300,2019-08-15 19:37:25 +0300]" (String) has invalid type for :range violates constraints (undefined method `exclude_begin?' for "[2019-08-15 19:37:25 +0300,2019-08-15 19:37:25 +0300]":String failed)

This issue may be related to #286 (ruby ranges not working), but with latest rom/dry updates even ROM::SQL::Postgres::Values::Range does not work.

@cutalion cutalion added the bug label Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant