lib/rom/sql/associations/many_to_many.rb in rom-sql-3.6.4 vs lib/rom/sql/associations/many_to_many.rb in rom-sql-4.0.0.alpha1

- old
+ new

@@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'rom/associations/many_to_many' -require 'rom/sql/associations/core' -require 'rom/sql/associations/self_ref' +require "rom/associations/many_to_many" +require "rom/sql/associations/core" +require "rom/sql/associations/self_ref" module ROM module SQL module Associations class ManyToMany < ROM::Associations::ManyToMany @@ -15,14 +15,14 @@ def call(target: self.target) left = join_assoc.(target: target) schema = if left.schema.key?(foreign_key) - if target != self.target - target.schema.merge(join_schema) - else + if target == self.target left.schema.uniq.project(*columns) + else + target.schema.merge(join_schema) end else target_schema end.qualified @@ -48,10 +48,10 @@ joined.__send__(type, target_ds, through_jk).qualified end # @api public def join_keys - { source_attr => target_attr } + {source_attr => target_attr} end # @api public def target_attr join_relation[target_key].qualified