How to use rom_factory with many to many relation

Hi! I have 3 relations:

class Talks < ROM::Relation[:sql]
  schema(:talks, infer: true) do
    associations do
      has_many :talks_speakers
      has_many :speakers, through: :talks_speakers
    end
  end

class Speakers < ROM::Relation[:sql]
  schema(:speakers, infer: true) do
    associations do
      has_many :talks_speakers
      has_many :talks, through: :talks_speakers
    end
  end

class TalksSpeakers < ROM::Relation[:sql]
  schema(:talks_speakers, infer: true) do
    associations do
      belongs_to :talk
      belongs_to :speaker
    end
 end

I want to obtain Talk ROM::Struct with Speakers. Is it possible?

Doesn’t f.association(:speakers) work in a factory definition block?

Unfortunately nope :frowning: Here is a stacktrace:

NameError:
  uninitialized constant ROM::Factory::Attributes::Association::ManyToMany
  Did you mean?  ROM::Factory::Attributes::Association::ManyToOne
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/attributes/association.rb:9:in `const_get'
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/attributes/association.rb:9:in `new'
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/dsl.rb:143:in `association'
# ./spec/support/factories/talk_fabricator.rb:14:in `block in <top (required)>'
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/dsl.rb:44:in `initialize'
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/factories.rb:231:in `new'
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/factories.rb:231:in `extend_builder'
# /usr/local/bundle/ruby/2.6.0/gems/rom-factory-0.10.1/lib/rom/factory/factories.rb:143:in `define'
# ./spec/support/factories/talk_fabricator.rb:13:in `<top (required)>'
# /usr/local/bundle/ruby/2.6.0/gems/hanami-utils-2.0.0.alpha1/lib/hanami/utils.rb:56:in `require_relative'
# /usr/local/bundle/ruby/2.6.0/gems/hanami-utils-2.0.0.alpha1/lib/hanami/utils.rb:56:in `block in require!'
# /usr/local/bundle/ruby/2.6.0/gems/hanami-utils-2.0.0.alpha1/lib/hanami/utils.rb:78:in `each'
# /usr/local/bundle/ruby/2.6.0/gems/hanami-utils-2.0.0.alpha1/lib/hanami/utils.rb:78:in `for_each_file_in'
# /usr/local/bundle/ruby/2.6.0/gems/hanami-utils-2.0.0.alpha1/lib/hanami/utils.rb:56:in `require!'
# ./spec/spec_helper.rb:20:in `<top (required)>'

OK this means it is not supported yet. You could report a feature request about it, this way you’ll get notified when it’s implemented.