This method is deprecated or moved on the latest stable version.
The last existing version (v6.0.0) is shown here.
resolve_symbol_connection(env_name, pool_name)
private
Takes the environment such as :production or :development
and a pool name the corresponds to the name given by the connection pool to
the connection. That pool name is merged into the hash with the name key.
This requires that the @configurations was initialized with a key that
matches.
# File activerecord/lib/active_record/connection_adapters/connection_specification.rb, line 245
def resolve_symbol_connection(env_name, pool_name)
db_config = configurations.find_db_config(env_name)
if db_config
resolve_connection(db_config.config).merge("name" => pool_name.to_s)
else
raise AdapterNotSpecified, <<~MSG
The `#{env_name}` database is not configured for the `#{ActiveRecord::ConnectionHandling::DEFAULT_ENV.call}` environment.
Available databases configurations are:
#{build_configuration_sentence}
MSG
end
end
def build_configuration_sentence # :nodoc:
configs = configurations.configs_for(include_replicas: true)
configs.group_by(&:env_name).map do |env, config|
namespaces = config.map(&:spec_name)
if namespaces.size > 1
"#{env}: #{namespaces.join(", ")}"
else
env
end
end.join("\n")
end
# Accepts a hash. Expands the "url" key that contains a
# URL database connection to a full connection
# hash and merges with the rest of the hash.
# Connection details inside of the "url" key win any merge conflicts
def resolve_hash_connection(spec)
if spec["url"] && spec["url"] !~ /^jdbc:/
connection_hash = resolve_url_connection(spec.delete("url"))
spec.merge!(connection_hash)
end
spec
end
# Takes a connection URL.
#
# Resolver.new({}).resolve_url_connection("postgresql://localhost/foo")
# # => { "host" => "localhost", "database" => "foo", "adapter" => "postgresql" }
#
def resolve_url_connection(url)
ConnectionUrlResolver.new(url).to_hash
end
end