aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 00:32:18 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-01-04 11:58:43 -0300
commitefdc20f36ccc37afbb2705eb9acca76dd8aabd4f (patch)
treefe161a52467b1316109df366d5fbe76c6e87fde7 /activerecord
parenta939506f297b667291480f26fa32a373a18ae06a (diff)
downloadrails-efdc20f36ccc37afbb2705eb9acca76dd8aabd4f.tar.gz
rails-efdc20f36ccc37afbb2705eb9acca76dd8aabd4f.tar.bz2
rails-efdc20f36ccc37afbb2705eb9acca76dd8aabd4f.zip
Remove deprecated access to connection specification using a string acessor.
Now all strings will be handled as a URL.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md6
-rw-r--r--activerecord/lib/active_record/connection_adapters/connection_specification.rb21
-rw-r--r--activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb38
3 files changed, 7 insertions, 58 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 6d01bc67ce..72410ab496 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,9 @@
+* Remove deprecated access to connection specification using a string acessor.
+
+ Now all strings will be handled as a URL.
+
+ *Rafael Mendonça França*
+
* Change the default `null` value for `timestamps` to `false`.
*Rafael Mendonça França*
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
index e54e3199ff..08d46fca96 100644
--- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
@@ -1,5 +1,4 @@
require 'uri'
-require 'active_support/core_ext/string/filters'
module ActiveRecord
module ConnectionAdapters
@@ -210,30 +209,12 @@ module ActiveRecord
when Symbol
resolve_symbol_connection spec
when String
- resolve_string_connection spec
+ resolve_url_connection spec
when Hash
resolve_hash_connection spec
end
end
- def resolve_string_connection(spec)
- # Rails has historically accepted a string to mean either
- # an environment key or a URL spec, so we have deprecated
- # 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(<<-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+.
# This requires that the @configurations was initialized with a key that
# matches.
diff --git a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
index 37ad469476..9ee92a3cd2 100644
--- a/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
+++ b/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb
@@ -51,34 +51,6 @@ module ActiveRecord
assert_equal expected, actual
end
- def test_resolver_with_database_uri_and_and_current_env_string_key
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- config = { "default_env" => { "adapter" => "not_postgres", "database" => "not_foo" } }
- actual = assert_deprecated { resolve_spec("default_env", config) }
- expected = { "adapter"=>"postgresql", "database"=>"foo", "host"=>"localhost" }
- assert_equal expected, actual
- end
-
- def test_resolver_with_database_uri_and_and_current_env_string_key_and_rails_env
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- ENV['RAILS_ENV'] = "foo"
-
- config = { "not_production" => {"adapter" => "not_postgres", "database" => "not_foo" } }
- actual = assert_deprecated { resolve_spec("foo", config) }
- expected = { "adapter" => "postgresql", "database" => "foo", "host" => "localhost" }
- assert_equal expected, actual
- end
-
- def test_resolver_with_database_uri_and_and_current_env_string_key_and_rack_env
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- ENV['RACK_ENV'] = "foo"
-
- config = { "not_production" => {"adapter" => "not_postgres", "database" => "not_foo" } }
- actual = assert_deprecated { resolve_spec("foo", config) }
- expected = { "adapter" => "postgresql", "database" => "foo", "host" => "localhost" }
- assert_equal expected, actual
- end
-
def test_resolver_with_database_uri_and_known_key
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "production" => { "adapter" => "not_postgres", "database" => "not_foo", "host" => "localhost" } }
@@ -95,16 +67,6 @@ module ActiveRecord
end
end
- def test_resolver_with_database_uri_and_unknown_string_key
- ENV['DATABASE_URL'] = "postgres://localhost/foo"
- config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }
- assert_deprecated do
- assert_raises AdapterNotSpecified do
- resolve_spec("production", config)
- end
- end
- end
-
def test_resolver_with_database_uri_and_supplied_url
ENV['DATABASE_URL'] = "not-postgres://not-localhost/not_foo"
config = { "production" => { "adapter" => "also_not_postgres", "database" => "also_not_foo" } }