<commit_before>module ActiveRecord
  module With
    module QueryMethods
      def with!(with_values)
        @values[:with] = (@values[:with] || {}).merge(with_values)
        self
      end
      
      def with(with_values)
        spawn.with!(with_values)
      end
      
      def build_arel
        arel = super
        build_with(arel)
        arel
      end
      
      def build_with(arel)
        return arel unless @values[:with]
        @values[:with].inject(arel) do |arel, (name, relation)|
          arel.with(Arel::Nodes::As.new(Arel::Table.new(name), Arel::SqlLiteral.new("(#{relation.to_sql})")))
        end
      end
    end
  end<commit_msg>use relation arel instead of stringifing and literaling<commit_after>module ActiveRecord
  module With
    module QueryMethods
      def with!(with_values)
        @values[:with] = (@values[:with] || {}).merge(with_values)
        self
      end
      
      def with(with_values)
        spawn.with!(with_values)
      end
      
      def build_arel
        arel = super
        build_with(arel)
        arel
      end
      
      def build_with(arel)
        return arel unless @values[:with]
        @values[:with].inject(arel) do |arel, (name, relation)|
          arel.with(Arel::Nodes::As.new(Arel::Table.new(name), relation.arel))
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.11202389843166542, 'fraction_numerical': 0.0, 'mean_word_length': 2.0804597701149423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7044849', 'n_tokens_mistral': 412, 'n_tokens_neox': 407, 'n_words': 88}