<commit_before>module ActiveRecord
  module Associations
    class AssociationScope #:nodoc:
      attr_reader :association, :alias_tracker

      delegate :klass, :owner, :reflection, :to => :association
      delegate :chain, :scope_chain, :options, :to => :reflection

      def initialize(association)
        @association   = association
        @alias_tracker = AliasTracker.new klass.connection
      end

      def scope
        scope = klass.unscoped
        scope.extending! Array(options[:extend])
        add_constraints(scope)
      end

      def join_type
        Arel::Nodes::InnerJoin
      end

      private

      def construct_tables
        chain.map do |reflection|
          alias_tracker.aliased_table_for(
            table_name_for(reflection),
            table_alias_for(reflection, reflection != self.reflection)
          )
        end
      end


      def table_alias_for(reflection, join = false)
        name = "#{reflection.plural_name}_#{alias_suffix}"
        name << "_join" if join
        name
      end

      def join(table, constraint)
        table.create_join(table, table.create_on(constraint), join_type)
      end

      def column_for(table_name, column_name)
        columns = alias_tracker.connection.schema_cache.columns_hash(table_name)
        columns[column_name]
      end

      def bind_value(scope, column, value)<commit_msg>:scissors: whitespace<commit_after>module ActiveRecord
  module Associations
    class AssociationScope #:nodoc:
      attr_reader :association, :alias_tracker

      delegate :klass, :owner, :reflection, :to => :association
      delegate :chain, :scope_chain, :options, :to => :reflection

      def initialize(association)
        @association   = association
        @alias_tracker = AliasTracker.new klass.connection
      end

      def scope
        scope = klass.unscoped
        scope.extending! Array(options[:extend])
        add_constraints(scope)
      end

      def join_type
        Arel::Nodes::InnerJoin
      end

      private

      def construct_tables
        chain.map do |reflection|
          alias_tracker.aliased_table_for(
            table_name_for(reflection),
            table_alias_for(reflection, reflection != self.reflection)
          )
        end
      end

      def table_alias_for(reflection, join = false)
        name = "#{reflection.plural_name}_#{alias_suffix}"
        name << "_join" if join
        name
      end

      def join(table, constraint)
        table.create_join(table, table.create_on(constraint), join_type)
      end

      def column_for(table_name, column_name)
        columns = alias_tracker.connection.schema_cache.columns_hash(table_name)
        columns[column_name]
      end

      def bind_value(scope, column, value)
{'fraction_non_alphanumeric': 0.0806625855239467, 'fraction_numerical': 0.0, 'mean_word_length': 2.4943396226415095, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '980845', 'n_tokens_mistral': 803, 'n_tokens_neox': 785, 'n_words': 170}