aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/connection_specification.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/connection_specification.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/connection_specification.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
index 2fcb085ab2..e54e3199ff 100644
--- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
@@ -1,4 +1,5 @@
require 'uri'
+require 'active_support/core_ext/string/filters'
module ActiveRecord
module ConnectionAdapters
@@ -32,8 +33,8 @@ module ActiveRecord
# }
def initialize(url)
raise "Database URL cannot be empty" if url.blank?
- @uri = URI.parse(url)
- @adapter = @uri.scheme.gsub('-', '_')
+ @uri = uri_parser.parse(url)
+ @adapter = @uri.scheme.tr('-', '_')
@adapter = "postgresql" if @adapter == "postgres"
if @uri.opaque
@@ -160,7 +161,7 @@ module ActiveRecord
# config = { "production" => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" } }
# spec = Resolver.new(config).spec(:production)
# spec.adapter_method
- # # => "sqlite3"
+ # # => "sqlite3_connection"
# spec.config
# # => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" }
#
@@ -221,15 +222,19 @@ module ActiveRecord
# this ambiguous behaviour and in the future this function
# can be removed in favor of resolve_url_connection.
if configurations.key?(spec) || spec !~ /:/
- ActiveSupport::Deprecation.warn "Passing a string to ActiveRecord::Base.establish_connection " \
- "for a configuration lookup is deprecated, please pass a symbol (#{spec.to_sym.inspect}) instead"
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ Passing a string to ActiveRecord::Base.establish_connection for a
+ configuration lookup is deprecated, please pass a symbol
+ (#{spec.to_sym.inspect}) instead.
+ MSG
+
resolve_symbol_connection(spec)
else
resolve_url_connection(spec)
end
end
- # Takes the environment such as `:production` or `:development`.
+ # Takes the environment such as +:production+ or +:development+.
# This requires that the @configurations was initialized with a key that
# matches.
#
@@ -250,7 +255,7 @@ module ActiveRecord
# 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_string_connection(spec.delete("url"))
+ connection_hash = resolve_url_connection(spec.delete("url"))
spec.merge!(connection_hash)
end
spec