aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-03-14 15:59:16 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-03-14 15:59:16 -0500
commit03edba1466114a3e1bd657b11164bb637a565fac (patch)
treefce89f2261d965584f2f88a352dee70575113d0f /activerecord
parentd17b87919fae5850051bf7a173d3c6a84778f941 (diff)
parentaa27766e2fa8ba92b0943e829b7e91b7518a777d (diff)
downloadrails-03edba1466114a3e1bd657b11164bb637a565fac.tar.gz
rails-03edba1466114a3e1bd657b11164bb637a565fac.tar.bz2
rails-03edba1466114a3e1bd657b11164bb637a565fac.zip
Merge pull request #14373 from schneems/schneems/jdbc-ar-2
Allow custom JDBC urls
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/connection_specification.rb4
-rw-r--r--activerecord/test/cases/connection_adapters/connection_handler_test.rb6
2 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
index 3f8b14bf67..9a133168f8 100644
--- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb
@@ -237,8 +237,8 @@ module ActiveRecord
# 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 url = spec.delete("url")
- connection_hash = resolve_string_connection(url)
+ if spec["url"] && spec["url"] !~ /^jdbc:/
+ connection_hash = resolve_string_connection(spec.delete("url"))
spec.merge!(connection_hash)
end
spec
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
index 599e8c762c..68ddc08f89 100644
--- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb
+++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -17,6 +17,12 @@ module ActiveRecord
ENV["DATABASE_URL"] = @previous_database_url
end
+ def test_jdbc_url
+ config = { "production" => { "url" => "jdbc:postgres://localhost/foo" } }
+ actual = klass.new(config).resolve
+ assert_equal config, actual
+ end
+
def test_environment_does_not_exist_in_config_url_does_exist
ENV['DATABASE_URL'] = "postgres://localhost/foo"
config = { "not_production" => { "adapter" => "not_postgres", "database" => "not_foo" } }