mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Allow pg query param syntax
Allow configuring Postgres password through the socket URL. For example: ```ruby ActiveRecord::DatabaseConfigurations::UrlConfig.new( :production, :production, 'postgres:///?user=user&password=secret&dbname=app', {} ).configuration_hash ``` will now return, ```ruby { :user=>"user", :password=>"secret", :dbname=>"app", :adapter=>"postgresql" } ```
This commit is contained in:
parent
ee98178ea5
commit
c9b25c89ae
3 changed files with 30 additions and 1 deletions
|
@ -80,6 +80,23 @@
|
|||
|
||||
*Kevin Newton*
|
||||
|
||||
* Allow configuring Postgres password through the socket URL.
|
||||
|
||||
For example:
|
||||
```ruby
|
||||
ActiveRecord::DatabaseConfigurations::UrlConfig.new(
|
||||
:production, :production, 'postgres:///?user=user&password=secret&dbname=app', {}
|
||||
).configuration_hash
|
||||
```
|
||||
|
||||
will now return,
|
||||
|
||||
```ruby
|
||||
{ :user=>"user", :password=>"secret", :dbname=>"app", :adapter=>"postgresql" }
|
||||
```
|
||||
|
||||
*Abeid Ahmed*
|
||||
|
||||
* Fix `eager_loading?` when ordering with `Symbol`
|
||||
|
||||
`eager_loading?` is triggered correctly when using `order` with symbols.
|
||||
|
|
|
@ -67,7 +67,7 @@ module ActiveRecord
|
|||
database: uri.opaque
|
||||
)
|
||||
else
|
||||
query_hash.merge(
|
||||
query_hash.reverse_merge(
|
||||
adapter: @adapter,
|
||||
username: uri.user,
|
||||
password: uri.password,
|
||||
|
|
|
@ -62,6 +62,18 @@ module ActiveRecord
|
|||
}, pool_config.configuration_hash)
|
||||
end
|
||||
|
||||
def test_url_sub_key_merges_correctly_when_query_param
|
||||
hash = { "url" => "abstract:///?user=user&password=passwd&dbname=app" }
|
||||
pool_config = resolve_db_config :production, "production" => hash
|
||||
|
||||
assert_equal({
|
||||
adapter: "abstract",
|
||||
user: "user",
|
||||
password: "passwd",
|
||||
dbname: "app"
|
||||
}, pool_config.configuration_hash)
|
||||
end
|
||||
|
||||
def test_url_host_no_db
|
||||
pool_config = resolve_db_config "abstract://foo?encoding=utf8"
|
||||
assert_equal({
|
||||
|
|
Loading…
Reference in a new issue