mirror of https://github.com/rails/rails
Merge pull request #37738 from joshuaflanagan/allow_equals_in_db_url_query_value
Database URL supports query value with equal sign
This commit is contained in:
commit
32b363b246
|
@ -12,6 +12,10 @@
|
|||
|
||||
*Jeff Emminger*, *Gannon McGibbon*
|
||||
|
||||
* A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgresSQL `options`.
|
||||
|
||||
*Joshua Flanagan*
|
||||
|
||||
* Calling methods like `establish_connection` with a `Hash` which is invalid (eg: no `adapter`) will now raise an error the same way as connections defined in `config/database.yml`.
|
||||
|
||||
*John Crepezzi*
|
||||
|
|
|
@ -57,7 +57,7 @@ module ActiveRecord
|
|||
# "localhost"
|
||||
# # => {}
|
||||
def query_hash
|
||||
Hash[(@query || "").split("&").map { |pair| pair.split("=") }].symbolize_keys
|
||||
Hash[(@query || "").split("&").map { |pair| pair.split("=", 2) }].symbolize_keys
|
||||
end
|
||||
|
||||
def raw_config
|
||||
|
|
|
@ -171,6 +171,13 @@ module ActiveRecord
|
|||
assert_not_includes actual, :url
|
||||
end
|
||||
|
||||
def test_url_with_equals_in_query_value
|
||||
config = { "default_env" => { "url" => "postgresql://localhost/foo?options=-cmyoption=on" } }
|
||||
actual = resolve_config(config)
|
||||
expected = { options: "-cmyoption=on", adapter: "postgresql", database: "foo", host: "localhost" }
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
def test_hash
|
||||
config = { "production" => { "adapter" => "postgres", "database" => "foo" } }
|
||||
actual = resolve_config(config, "production")
|
||||
|
|
Loading…
Reference in New Issue