Rom-sql relation's `fetch` doesn't seem to support mapping

I’ve created a finder method on my repository. When calling fetch on the association while specifying map_with, the resulting entity is a struct instead of the mapped class.

def by_id(event_id)
  events.map_with(:mapped_event_mapper).fetch(event_id)
end

# Example:

repo.by_id(123)
# => #<ROM::Struct::Event id="...">

However, when I use the same rom-sql code that’s used internally by fetch (Discourse won’t let me link to GitHub), it works:

def by_id(event_id)
  events.map_with(:mapped_event_mapper).by_pk(event_id).one!
end

# Example:

repo.by_id(123)
# => #<MappedEvent id="...">

fetch calls by_pk(event_id).one! internally, so it’s odd this behavior differs.

Are you using latest rom and latest rom-mapper? I fixed a couple of things in #map_with so maybe that’s it.

Hi @solnic, yes, been using the latest. Ended up not using fetch.