Sha256: dd69aa308136a0237abf3c2bee79675471133a6445f3e0a2c0ffd073b796eba4
Contents?: true
Size: 1019 Bytes
Versions: 5
Compression:
Stored size: 1019 Bytes
Contents
module ActiveRecord # :nodoc: module ConnectionHandling # :nodoc: require 'pg' # Based on the default <tt>postgresql_connection</tt> definition from # ActiveRecord. def postgis_connection(config_) # FULL REPLACEMENT because we need to create a different class. 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. conn_params_.keep_if { |k_, _| VALID_CONN_PARAMS.include?(k_) } # The postgres drivers don't allow the creation of an unconnected PGconn object, # so just pass a nil connection object for the time being. ::ActiveRecord::ConnectionAdapters::PostGISAdapter::MainAdapter.new(nil, logger, conn_params_, config_) end end end
Version data entries
5 entries across 5 versions & 2 rubygems