Merge pull request #23472 from jhubert/patch-2

Remove the assumption of schema in DATABASE_URL
This commit is contained in:
Rafael França 2016-02-05 00:23:32 -02:00
commit 22af61984c
2 changed files with 7 additions and 1 deletions

View File

@ -33,7 +33,7 @@ module ActiveRecord
def initialize(url)
raise "Database URL cannot be empty" if url.blank?
@uri = uri_parser.parse(url)
@adapter = @uri.scheme.tr('-', '_')
@adapter = @uri.scheme && @uri.scheme.tr('-', '_')
@adapter = "postgresql" if @adapter == "postgres"
if @uri.opaque

View File

@ -57,6 +57,12 @@ module ActiveRecord
"encoding" => "utf8" }, spec)
end
def test_url_missing_scheme
spec = resolve 'foo'
assert_equal({
"database" => "foo" }, spec)
end
def test_url_host_db
spec = resolve 'abstract://foo/bar?encoding=utf8'
assert_equal({