rom-rb / rom

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

Rails 7.1 Upgrade Causes map_with To Throw ArgumentError #691

Closed bendangelo closed 2 months ago

bendangelo commented 2 months ago

Describe the bug

Using rom-core 5.3.1, rails 7.1.3.2

The map_with interface in the relationship.rb file breaks when running rails 7.1+ but works fine on rails 7.0.

Error given: ArgumentError: wrong number of arguments (given 1, expected 0)

To Reproduce

Create a basic mapping:

  class Mapping < ROM::Repository[:schedules]

    commands :create, update: :by_pk,
      mapper: :mapping_mapper,
      use: :timestamps, plugins_options: {timestamps: {timestamps: %i[created_at updated_at]}}

def by_id id
schedules.map_with(:mapping_mapper).by_pk(id).one
end
end

# run by_id method
mapping.by_id 10 => # argument error

Note .by_pk and .one are not a factor.

Expected behavior

I expect map_with to work as it does when running rails 7.0. I've downgraded and upgraded and the only difference is the rails upgrade.

My environment

hellvinz commented 2 months ago

I think the fix for this issue https://github.com/rom-rb/rom/issues/684 does not work for map_with. undef :with here seems to do the trick

flash-gordon commented 2 months ago

Thanks for reporting, it was fixed in 5.3.2, please check it out

bendangelo commented 1 month ago

thanks