I have a rom-sql project and use auto-struct with custom entity classes. That works perfectly. My repos return instances and their association-instances of my custom entity classes. However, as soon as I use the as option in an association definition, the association result is no longer mapped to the corresponding entity.
To Reproduce
module Orm
module Relations
class Posts < ROM::Relation[:sql]
schema(:posts, infer: true) do
associations do
belongs_to :user, as: :create_user, foreign_key: :created_by
belongs_to :user, as: :update_user, foreign_key: :updated_by
end
end
end
end
end
post = posts.combine(:create_user)
.by_pk(1).one
expect(post).to be_a(Entities::Post) # success
expect(post.create_user).to be_a(Entities::User) # fails it is a instance of Entities::CreateUser
Describe the bug
I have a rom-sql project and use auto-struct with custom entity classes. That works perfectly. My repos return instances and their association-instances of my custom entity classes. However, as soon as I use the
as
option in an association definition, the association result is no longer mapped to the corresponding entity.To Reproduce
Expected behavior
My environment