Sha256: e0e65c0b1ae805d64ef2af157464257b1e66462c845e7a545045830a4ea1d2c8

Contents?: true

Size: 1003 Bytes

Versions: 27

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

module ArJdbc
  ConnectionMethods = ::ActiveRecord::ConnectionHandling

  ConnectionMethods.module_eval do

    def jdbc_connection(config)
      adapter_class = config[:adapter_class] || ::ActiveRecord::ConnectionAdapters::JdbcAdapter
      adapter_class.new(nil, logger, nil, config)
    end

    def jndi_connection(config); jdbc_connection(config) end

    def embedded_driver(config)
      config[:username] ||= "sa"
      config[:password] ||= ""
      jdbc_connection(config)
    end

    private

    def jndi_config?(config)
      ::ActiveRecord::ConnectionAdapters::JdbcConnection.jndi_config?(config)
    end

    # @note keeps the same Hash when possible - helps caching on native side
    def symbolize_keys_if_necessary(hash)
      symbolize = false
      hash.each_key do |key|
        if ! key.is_a?(Symbol) && key.respond_to?(:to_sym)
          symbolize = true; break
        end
      end
      symbolize ? hash.symbolize_keys : hash
    end

  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
activerecord-jdbc-alt-adapter-61.3.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-70.2.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-70.2-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-61.3-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-70.1.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-70.0.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-70.1-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-70.0.0.rc2-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-60.3.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-61.2.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-70.0.0.rc1-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-70.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-70.0.pre-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-61.2-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-60.2.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-61.1.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-61.1-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-60.4-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-61.0.0-java lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-alt-adapter-60.1.0-java lib/arjdbc/jdbc/connection_methods.rb