#1525·hanami

DB layer does not use slice-level inflections

Author: aaronmallenCreated Jun 24, 2025Updated Oct 4, 2025

[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

  1. Create an inflection rule in a slice:
ruby
module MySlice
  class Slice < Hanami::Slice
    config.inflections do |inflect|
      inflect.acronym 'RSA'
    end
  end
end
  1. Create a relations/repos: RSAKeys, RSAKeyRepo
  2. Create a repo method that returns a struct
  3. Observe the returned struct is named RsaKey