rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.08k stars 161 forks source link

Incompatible with dry-initializer 2.6.0 #503

Closed gingerhendrix closed 5 years ago

gingerhendrix commented 5 years ago

Describe the bug

Attempting to use Commands fails with a Dry::Types::ContraintError

/home/gareth/.rvm/gems/ruby-2.5.1/gems/dry-types-0.12.2/lib/dry/types/constrained.rb:28:in `block in call': nil violates constraints (type?(Symbol, nil) AND included_in?([:create, :update, :delete], nil) failed) (Dry::Types::ConstraintError)

Forcing the previous version of dry-initializer solves the problem.

see: https://github.com/dry-rb/dry-initializer/blob/master/CHANGELOG.md#260-2018-09-09

To Reproduce

Gemfile:

source "https://rubygems.org"

gem "rom"
gem "rom-sql"
gem "sqlite3"

Output of bundle list:

Gems included by the bundle:
  * bundler (1.16.2)
  * concurrent-ruby (1.0.5)
  * dry-configurable (0.7.0)
  * dry-container (0.6.0)
  * dry-core (0.4.7)
  * dry-equalizer (0.2.1)
  * dry-inflector (0.1.2)
  * dry-initializer (2.6.0)
  * dry-logic (0.4.2)
  * dry-struct (0.4.0)
  * dry-types (0.12.3)
  * ice_nine (0.11.2)
  * inflecto (0.0.2)
  * rom (4.2.1)
  * rom-changeset (1.0.2)
  * rom-core (4.2.1)
  * rom-mapper (1.2.1)
  * rom-repository (2.0.2)
  * rom-sql (2.5.0)
  * sequel (5.12.0)
  * sqlite3 (1.3.13)
  * transproc (1.0.2)

Example script from: https://github.com/rom-rb/rom/blob/master/repository/examples/sql.rb

require 'rom-repository'

conf = ROM::Configuration.new(:sql, 'sqlite::memory')

migration = conf.gateways[:default].migration do
  change do
    create_table(:users) do
      primary_key :id
      column :name, String, null: false
      column :email, String, null: false
    end
  end
end

migration.apply(conf.gateways[:default].connection, :up)

class Users < ROM::Relation[:sql]
  schema(infer: true)

  def by_id(id)
    where(id: id)
  end
end

conf.register_relation(Users)
rom = ROM.container(conf)

class UserRepo < ROM::Repository[:users]
  commands :create, update: :by_id, delete: :by_id

  def [](id)
    users.by_id(id).one!
  end

  def all
    users.to_a
  end
end

user_repo = UserRepo.new(rom)

user = user_repo.create(name: 'Jane', email: 'jane@doe.org')

puts user.inspect

Expected behavior

Should run without exceptions.

Workaround

Adding

gem 'dry-initializer', "2.4.0"

and running bundle update solves the problem.

Your environment

solnic commented 5 years ago

hey @nepalez why did this start breaking?

flash-gordon commented 5 years ago

@gingerhendrix thanks for reporting

nepalez commented 5 years ago

@solnic Sorry, but I can do nothing for now because I’m on vacation without any notebook. I could look at it only in a week. It’s sad, but the only proposal from me for now is locking the dependency at 2.5.0

timriley commented 5 years ago

@nepalez is there any way you could eg. change your rubygems.org password, from your phone, then privately share it with one of us so that we could log in, grant access to the gem to the rest of the core team, and then we can coordinate the gem yanking/republishing from there?

I imagine this could be done without your laptop?

nepalez commented 5 years ago

Hi @timriley Yes, I could send it you via keybase.io (nepalez as usual)

timriley commented 5 years ago

@nepalez Great, thank you! I just followed you on key base. tbh I'm not 100% sure how it's meant to work but I am ready to receive your login details.

nepalez commented 5 years ago

Bingo! I’ve sent you the creds

timriley commented 5 years ago

@nepalez Mind checking key base again and letting me into the chat? I had problems with my account and had to reset things 🙄

nepalez commented 5 years ago

@timriley done

timriley commented 5 years ago

@nepalez I'm sorry mate, I seriously can't seem to get keybase to work. Your earlier messages show errors for me and new chat lines I initiate all fail. Can you send me the password in some other way? (at worst, you can use the email listed on my GitHub profile)

timriley commented 5 years ago

Or maybe you could try the standard keybase plain message encryption: https://keybase.io/encrypt

timriley commented 5 years ago

@nepalez You may need to "refresh" my profile on keybase since I set it up with a new key/proof earlier.

timriley commented 5 years ago

@nepalez I have to go to sleep now. Can you please coordinate the password exchange with @solnic or @flash-gordon? It'd be good to get this resolved properly today.

solnic commented 5 years ago

FYI I just pinged @nepalez on keybase

nepalez commented 5 years ago

@solnic I’ve sent the creds to you on the keybase

timriley commented 5 years ago

I've yanked dry-initializer 2.6.0 and have updated its CHANGELOG accordingly.

I'll open another issue on dry-initializer to start discussion around the best way to release the breaking change.