Skip to content

Commit

Permalink
handle database urls that are missing schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
lsylvester committed Aug 1, 2024
1 parent ed553cc commit 40118ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def raw_config

def resolved_adapter
adapter = uri.scheme && @uri.scheme.tr("-", "_")
adapter = ActiveRecord.protocol_adapters[adapter] || adapter
adapter = ActiveRecord.protocol_adapters[adapter] || adapter if adapter
adapter
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,16 @@ def test_protocol_adapter_mapping_handles_sqlite3_file_urls

assert_equal expected, actual.configuration_hash
end

def test_protocol_adapter_mapping_handles_missing_scheme_in_url
ENV["DATABASE_URL"] = "//localhost/exampledb"
ENV["RAILS_ENV"] = "production"

actual = resolve_db_config(:production, { "production" => { "adapter" => "abstract" } })
expected = { adapter: "abstract", database: "exampledb", host: "localhost" }

assert_equal expected, actual.configuration_hash
end
end
end
end

0 comments on commit 40118ba

Please sign in to comment.