<commit_before>require 'rom/associations/many_to_many'
require 'rom/sql/associations/core'

module ROM
  module SQL
    module Associations
      class ManyToMany < ROM::Associations::ManyToMany
        include Associations::Core

        # @api public
        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
                left.schema.project(*columns)
              end
            else
              target_schema
            end.qualified

          relation = left.join(source.name.dataset, join_keys)

          if view
            apply_view(schema, relation)
          else
            schema.(relation)
          end
        end

        # @api public
        def join(type, source = self.source, target = self.target)
          through_assoc = source.associations[through]
          joined = through_assoc.join(type, source)
          joined.__send__(type, target.name.dataset, join_keys).qualified
        end

        # @api public
        def join_keys
          with_keys { |source_key, target_key|
            { source[source_key].qualified => join_relation[target_key].qualified }
          }
        end

        # @api private
        def persist(children, parents)
          join_tuples = associate(children, parents)
          join_relation.multi_insert(join_tuples)
        end

        private

        # @api private
        def join_assoc
          join_relation.associations[target.name]
        end

        # @api private
        def target_schema
          target.schema.merge(join_schema)
        end

        # @api private
        def join_schema
          join_relation.schema.project(foreign_key)
        end

        # @api private
        def columns
          target_schema.map(&:name)
        end
      end
    end
  end
end<commit_msg>Remove method from ManyToMany that was moved to core<commit_after>require 'rom/associations/many_to_many'
require 'rom/sql/associations/core'

module ROM
  module SQL
    module Associations
      class ManyToMany < ROM::Associations::ManyToMany
        include Associations::Core

        # @api public
        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
                left.schema.project(*columns)
              end
            else
              target_schema
            end.qualified

          relation = left.join(source.name.dataset, join_keys)

          if view
            apply_view(schema, relation)
          else
            schema.(relation)
          end
        end

        # @api public
        def join(type, source = self.source, target = self.target)
          through_assoc = source.associations[through]
          joined = through_assoc.join(type, source)
          joined.__send__(type, target.name.dataset, join_keys).qualified
        end

        # @api public
        def join_keys
          with_keys { |source_key, target_key|
            { source[source_key].qualified => join_relation[target_key].qualified }
          }
        end

        # @api private
        def persist(children, parents)
          join_tuples = associate(children, parents)
          join_relation.multi_insert(join_tuples)
        end

        private

        # @api private
        def target_schema
          target.schema.merge(join_schema)
        end

        # @api private
        def join_schema
          join_relation.schema.project(foreign_key)
        end

        # @api private
        def columns
          target_schema.map(&:name)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07223942208462332, 'fraction_numerical': 0.0, 'mean_word_length': 1.6572995202193284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1546922', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1007, 'n_words': 227}