<commit_before>module MassInsert
  module Adapters
    class MysqlAdapter < Adapter

      def begin_of_string
        "INSERT INTO #{table_name} "
      end

      def string_columns
        "(#{column_names.join(", ")}) "
      end

      def string_values
        "VALUES (#{string_rows_values})"
      end

      def string_rows_values
        values.map{ |row| string_single_row_values(row) }.join("), (")
      end

      def string_single_row_values row
        sanitize_row_values(row)
        column_names.map{ |col| string_single_value(row, col) }.join(", ")
      end

      def string_single_value row, column
        case column_type(column)
        when :string, :text, :date, :datetime, :time, :timestamp
          row[column] ? "'#{row[column]}'" : "''"
        when :integer, :float, :decimal, :boolean, :binary
          row[column].to_s
        end
      end

      def execute
        begin_of_string << string_columns << string_values
      end

    end
  end
end<commit_msg>Solving errors in mysql adapter<commit_after>module MassInsert
  module Adapters
    class MysqlAdapter < Adapter

      def begin_of_string
        "INSERT INTO #{table_name} "
      end

      def string_columns
        "(#{column_names.join(", ")}) "
      end

      def string_values
        "VALUES (#{string_rows_values})"
      end

      def string_rows_values
        values.map{ |row| string_single_row_values(row) }.join("), (")
      end

      def string_single_row_values row
        sanitize_row_values(row)
        column_names.map{ |col| string_single_value(row, col) }.join(", ")
      end

      def string_single_value row, column
        case column_type(column)
        when :string, :text, :date, :datetime, :time, :timestamp
          row[column.to_sym] ? "'#{row[column]}'" : "''"
        when :integer, :float, :decimal, :boolean, :binary
          row[column.to_sym].to_s
        end
      end

      def execute
        begin_of_string << string_columns << string_values
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.1067193675889328, 'fraction_numerical': 0.0, 'mean_word_length': 2.3360790774299836, 'pattern_counts': {'":': 0, '<': 13, '<?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': '2481229', 'n_tokens_mistral': 638, 'n_tokens_neox': 627, 'n_words': 147}