Skip to content

Commit b2db4c7

Browse files
committed
Merge PR rails#42840
2 parents 6aeeb0c + c9b25c8 commit b2db4c7

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

activerecord/CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
* Allow configuring Postgres password through the socket URL.
2+
3+
For example:
4+
```ruby
5+
ActiveRecord::DatabaseConfigurations::UrlConfig.new(
6+
:production, :production, 'postgres:///?user=user&password=secret&dbname=app', {}
7+
).configuration_hash
8+
```
9+
10+
will now return,
11+
12+
```ruby
13+
{ :user=>"user", :password=>"secret", :dbname=>"app", :adapter=>"postgresql" }
14+
```
15+
16+
*Abeid Ahmed*
17+
118
* PostgreSQL: support custom enum types
219

320
In migrations, use `create_enum` to add a new enum type, and `t.enum` to add a column.

activerecord/lib/active_record/database_configurations/connection_url_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def raw_config
6767
database: uri.opaque
6868
)
6969
else
70-
query_hash.merge(
70+
query_hash.reverse_merge(
7171
adapter: @adapter,
7272
username: uri.user,
7373
password: uri.password,

activerecord/test/cases/database_configurations/resolver_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ def test_url_sub_key_merges_correctly
6262
}, pool_config.configuration_hash)
6363
end
6464

65+
def test_url_sub_key_merges_correctly_when_query_param
66+
hash = { "url" => "abstract:///?user=user&password=passwd&dbname=app" }
67+
pool_config = resolve_db_config :production, "production" => hash
68+
69+
assert_equal({
70+
adapter: "abstract",
71+
user: "user",
72+
password: "passwd",
73+
dbname: "app"
74+
}, pool_config.configuration_hash)
75+
end
76+
6577
def test_url_host_no_db
6678
pool_config = resolve_db_config "abstract://foo?encoding=utf8"
6779
assert_equal({

0 commit comments

Comments
 (0)