Yves, it could look like this:
```ruby
def association_key_type
  @klass.column_types[association_key_name.to_s].type
end

def owner_key_type
  @model.column_types[owner_key_name.to_s].type
end

# and then just to_s if they have different types.
owner_key = owner_key.to_s unless owner_key_type == association_key_type

owners_map[owner_key].each do |owner|
  records_by_owner[owner] << record
end
```

What do you think?