Module: ActiveRecord::ConnectionHandling
- Defined in:
- lib/active_record/connection_adapters/ovirt_legacy_postgresql_adapter.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#ovirt_legacy_postgresql_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
Instance Method Details
#ovirt_legacy_postgresql_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/active_record/connection_adapters/ovirt_legacy_postgresql_adapter.rb', line 27 def ovirt_legacy_postgresql_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 PGconn.connect. valid_conn_param_keys = PGconn.conndefaults_hash.keys + [:requiressl] conn_params.slice!(*valid_conn_param_keys) # The postgres drivers don't allow the creation of an unconnected PGconn object, # so just pass a nil connection object for the time being. ConnectionAdapters::OvirtLegacyPostgreSQLAdapter.new(nil, logger, conn_params, config) end |