lib/rom/sql/association/many_to_many.rb in rom-sql-1.0.0.rc1 vs lib/rom/sql/association/many_to_many.rb in rom-sql-1.0.0.rc2

- old
+ new

@@ -62,12 +62,17 @@ # @api private def associate(relations, children, parent) ((spk, sfk), (tfk, tpk)) = join_key_map(relations) - children.map { |tuple| - { sfk => tuple.fetch(spk), tfk => parent.fetch(tpk) } - } + case parent + when Array + parent.map { |p| associate(relations, children, p) }.flatten(1) + else + children.map { |tuple| + { sfk => tuple.fetch(spk), tfk => parent.fetch(tpk) } + } + end end # @api private def join_relation(relations) relations[through.relation]