Module: ActiveRecord::ConnectionHandling

Defined in:
lib/active_record/connection_adapters/redshift_7_0_adapter.rb,
lib/active_record/connection_adapters/redshift_7_1_adapter.rb

Overview

:nodoc:

Constant Summary collapse

RS_VALID_CONN_PARAMS =
%i[host hostaddr port dbname user password connect_timeout
client_encoding options application_name fallback_application_name
keepalives keepalives_idle keepalives_interval keepalives_count
tty sslmode requiressl sslcompression sslcert sslkey
sslrootcert sslcrl requirepeer krbsrvname gsslib service].freeze

Instance Method Summary collapse

Instance Method Details

#redshift_adapter_classObject



27
28
29
# File 'lib/active_record/connection_adapters/redshift_7_1_adapter.rb', line 27

def redshift_adapter_class
  ConnectionAdapters::RedshiftAdapter
end

#redshift_connection(config) ⇒ Object

Establishes a connection to the database that’s used by all Active Record objects



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_record/connection_adapters/redshift_7_0_adapter.rb', line 34

def redshift_connection(config)
  conn_params = config.symbolize_keys

  conn_params.delete_if { |_, v| v.nil? }

  # Map ActiveRecords param names to PGs.
  conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
  conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]

  # Forward only valid config params to PG::Connection.connect.
  conn_params.keep_if { |k, _| RS_VALID_CONN_PARAMS.include?(k) }

  # The postgres drivers don't allow the creation of an unconnected PG::Connection object,
  # so just pass a nil connection object for the time being.
  ConnectionAdapters::RedshiftAdapter.new(nil, logger, conn_params, config)
end