<commit_before># frozen_string_literal: true
ArJdbc::ConnectionMethods.module_eval do
  def sqlite3_connection(config)
    config[:adapter_spec] ||= ::ArJdbc::SQLite3
    config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)

    return jndi_connection(config) if jndi_config?(config)

    begin
      require 'jdbc/sqlite3'
      ::Jdbc::SQLite3.load_driver(:require) if defined?(::Jdbc::SQLite3.load_driver)
    rescue LoadError # assuming driver.jar is on the class-path
    end
    config[:driver] ||= 'org.sqlite.JDBC'

    parse_sqlite3_config!(config)
    database = config[:database] # NOTE: "jdbc:sqlite::memory:" syntax is supported
    config[:url] ||= "jdbc:sqlite:#{database == ':memory:' ? '' : database}"
    config[:connection_alive_sql] ||= 'SELECT 1'

    options = ( config[:properties] ||= {} )
    # NOTE: configuring from JDBC properties not supported on 3.7.2 :
    options['busy_timeout'] ||= config[:timeout] if config.key?(:timeout)

    jdbc_connection(config)
  end
  alias_method :jdbcsqlite3_connection, :sqlite3_connection

  private

  def parse_sqlite3_config!(config)
    database = ( config[:database] ||= config[:dbfile] ) # allow Rails relative path :
    if database != ':memory:' && defined?(Rails.root)
      config[:database] = File.expand_path(database, Rails.root.to_s)
      dirname = File.dirname(config[:database])
      Dir.mkdir(dirname) unless File.directory?(dirname)
    end
  end

end
<commit_msg>Fix one sqlite3-specific test in AR<commit_after># frozen_string_literal: true
ArJdbc::ConnectionMethods.module_eval do
  def sqlite3_connection(config)
    config[:adapter_spec] ||= ::ArJdbc::SQLite3
    config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)

    return jndi_connection(config) if jndi_config?(config)

    begin
      require 'jdbc/sqlite3'
      ::Jdbc::SQLite3.load_driver(:require) if defined?(::Jdbc::SQLite3.load_driver)
    rescue LoadError # assuming driver.jar is on the class-path
    end
    config[:driver] ||= 'org.sqlite.JDBC'

    if config[:timeout] && config[:timeout].to_s !~ /\A\d+\Z/
      raise TypeError.new "Timeout must be nil or a number (got: #{config[:timeout]})."
    end

    parse_sqlite3_config!(config)
    database = config[:database] # NOTE: "jdbc:sqlite::memory:" syntax is supported
    config[:url] ||= "jdbc:sqlite:#{database == ':memory:' ? '' : database}"
    config[:connection_alive_sql] ||= 'SELECT 1'

    options = ( config[:properties] ||= {} )
    # NOTE: configuring from JDBC properties not supported on 3.7.2 :
    options['busy_timeout'] ||= config[:timeout] if config.key?(:timeout)

    jdbc_connection(config)
  end
  alias_method :jdbcsqlite3_connection, :sqlite3_connection

  private

  def parse_sqlite3_config!(config)
    database = ( config[:database] ||= config[:dbfile] ) # allow Rails relative path :
    if database != ':memory:' && defined?(Rails.root)
      config[:database] = File.expand_path(database, Rails.root.to_s)
      dirname = File.dirname(config[:database])
      Dir.mkdir(dirname) unless File.directory?(dirname)
    end
  end

end

{'fraction_non_alphanumeric': 0.13828786453433678, 'fraction_numerical': 0.009093759799310128, 'mean_word_length': 4.5190311418685125, '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': '5203802', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1000, 'n_words': 209}