<commit_before>require 'active_record/connection_adapters/jdbcpostgresql_adapter'

# Extend JDBC's PostgreSQLAdapter implementation for compatibility with
# ActiveRecord's default PostgreSQLAdapter.
class ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
  # Add `query` method for compatibility
  def query(*args)
    select_rows(*args)
  end

  # Backport from master, so PostGIS adapater will work with current stable
  # activerecord-jdbc-adapter gem.
  #
  # https://github.com/jruby/activerecord-jdbc-adapter/pull/200
  unless method_defined?(:schema_search_path=)
    def schema_search_path=(schema_csv)
      if schema_csv
        execute "SET search_path TO #{schema_csv}"
        @schema_search_path = schema_csv
      end
    end
  end

  # Backport from master, so PostGIS adapater will work with current stable
  # activerecord-jdbc-adapter gem.
  #
  # https://github.com/jruby/activerecord-jdbc-adapter/pull/200
  unless method_defined?(:schema_search_path)
    # Returns the active schema search path.
    def schema_search_path
      @schema_search_path ||= exec_query('SHOW search_path', 'SCHEMA')[0]['search_path']
    end
  end
end

class ::ActiveRecord::Base
  # ActiveRecord looks for the postgis_connection factory method in
  # this class.
  #
  # Based on the default `postgresql_connection` definition from
  # activerecord-jdbc-adapter's:
  # lib/arjdbc/postgresql/connection_methods.rb
  def self.postgis_connection(config)
    require "arjdbc/postgresql"
    config[:host] ||= "localhost"<commit_msg>Fix JDBC connection under ActiveRecord 3.1.x.<commit_after>require 'active_record/connection_adapters/jdbcpostgresql_adapter'

# Extend JDBC's PostgreSQLAdapter implementation for compatibility with
# ActiveRecord's default PostgreSQLAdapter.
class ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
  # Add `query` method for compatibility
  def query(*args)
    select_rows(*args)
  end

  # Backport from master, so PostGIS adapater will work with current stable
  # activerecord-jdbc-adapter gem.
  #
  # https://github.com/jruby/activerecord-jdbc-adapter/pull/200
  unless method_defined?(:schema_search_path=)
    def schema_search_path=(schema_csv)
      if schema_csv
        execute "SET search_path TO #{schema_csv}"
        @schema_search_path = schema_csv
      end
    end
  end

  # Backport from master, so PostGIS adapater will work with current stable
  # activerecord-jdbc-adapter gem.
  #
  # https://github.com/jruby/activerecord-jdbc-adapter/pull/200
  unless method_defined?(:schema_search_path)
    # Returns the active schema search path.
    def schema_search_path
      @schema_search_path ||= exec_query('SHOW search_path', 'SCHEMA')[0]['search_path']
    end
  end

  # For ActiveRecord 3.1 compatibility: Add the "postgis" adapter to the
  # matcher of jdbc-like adapters.
  def self.visitor_for(pool)
    config = pool.spec.config
    adapter = config[:adapter]
    adapter_spec = config[:adapter_spec] || self
    if adapter =~ /^(jdbc|jndi|postgis)$/
      adapter_spec.arel2_visitors(config).values.first.new(pool)
    else
      adapter_spec.arel2_visitors(config)[adapter].new(pool)
    end
  end
end

class ::ActiveRecord::Base
  # ActiveRecord looks for the postgis_connection factory method in
  # this class.
  #
  # Based on the default `postgresql_connection` definition from
  # activerecord-jdbc-adapter's:
  # lib/arjdbc/postgresql/connection_methods.rb
  def self.postgis_connection(config)
    require "arjdbc/postgresql"
    config[:host] ||= "localhost"
{'fraction_non_alphanumeric': 0.09188577890867967, 'fraction_numerical': 0.005654509471303365, 'mean_word_length': 4.280597014925373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '1695902', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1074, 'n_words': 257}