提交 22af6198 编写于 作者: R Rafael França

Merge pull request #23472 from jhubert/patch-2

Remove the assumption of schema in DATABASE_URL
...@@ -33,7 +33,7 @@ class ConnectionUrlResolver # :nodoc: ...@@ -33,7 +33,7 @@ class ConnectionUrlResolver # :nodoc:
def initialize(url) def initialize(url)
raise "Database URL cannot be empty" if url.blank? raise "Database URL cannot be empty" if url.blank?
@uri = uri_parser.parse(url) @uri = uri_parser.parse(url)
@adapter = @uri.scheme.tr('-', '_') @adapter = @uri.scheme && @uri.scheme.tr('-', '_')
@adapter = "postgresql" if @adapter == "postgres" @adapter = "postgresql" if @adapter == "postgres"
if @uri.opaque if @uri.opaque
......
...@@ -57,6 +57,12 @@ def test_url_host_no_db ...@@ -57,6 +57,12 @@ def test_url_host_no_db
"encoding" => "utf8" }, spec) "encoding" => "utf8" }, spec)
end end
def test_url_missing_scheme
spec = resolve 'foo'
assert_equal({
"database" => "foo" }, spec)
end
def test_url_host_db def test_url_host_db
spec = resolve 'abstract://foo/bar?encoding=utf8' spec = resolve 'abstract://foo/bar?encoding=utf8'
assert_equal({ assert_equal({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册