DB layer does not use slice-level inflections
[Renamed and summarised below by @timriley]
Inflections in our DB-layer (like finding struct classes from repos) do not respect inflection rules defined on a slice. They use the app-level inflections only. Ideally, a DB layer specific to a slice would respect the slice's inflections.
The issue behind this is that Rom v5 has only single global inflector, which we set to be the Hanami app-level inflector. We'll need to work on allowing Rom to have support per-container inflectors before we can support this in Hanami.
Original report from @aaronmallen:
Problem
Hanami DB structs do not currently respect inflections and auto structs are created as if the inflection doesn't exist. This means we are unable to define the struct manually (to populate with custom methods) as defining the struct with the appropriate inflection gets ignored by ROM and creating a struct that matches what ROM expects will raise a zeitwerk error.
Expected Behavior
Given an inflection exists the struct should be created with respect to it's inflected name.
Steps to reproduce
- Create an inflection rule in a slice:
module MySlice
class Slice < Hanami::Slice
config.inflections do |inflect|
inflect.acronym 'RSA'
end
end
end- Create a relations/repos:
RSAKeys,RSAKeyRepo - Create a repo method that returns a struct
- Observe the returned struct is named
RsaKey
Source: hanami/hanami