Sha256: 4cf1e827acecb67397c8ee93208c153523d48e49933d4e5386ef1efd9fa89d56

Contents?: true

Size: 962 Bytes

Versions: 3

Compression:

Stored size: 962 Bytes

Contents

ArJdbc::ConnectionMethods.module_eval do
  def postgresql_connection(config)
    begin
      require 'jdbc/postgres'
      ::Jdbc::Postgres.load_driver(:require) if defined?(::Jdbc::Postgres.load_driver)
    rescue LoadError # assuming driver.jar is on the class-path
    end

    config[:host] ||= "localhost"
    config[:port] ||= 5432
    config[:username] ||= Java::JavaLang::System.get_property("user.name")
    config[:url] ||= "jdbc:postgresql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
    config[:url] << config[:pg_params] if config[:pg_params]
    config[:driver] ||= defined?(::Jdbc::Postgres.driver_name) ? ::Jdbc::Postgres.driver_name : 'org.postgresql.Driver'
    config[:adapter_spec] ||= ::ArJdbc::PostgreSQL
    config[:adapter_class] = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter unless config.key?(:adapter_class)

    jdbc_connection(config)
  end
  alias_method :jdbcpostgresql_connection, :postgresql_connection
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.1 lib/arjdbc/postgresql/connection_methods.rb
activerecord-jdbc-adapter-1.3.0 lib/arjdbc/postgresql/connection_methods.rb
activerecord-jdbc-adapter-1.3.0.rc1 lib/arjdbc/postgresql/connection_methods.rb