diff --git a/conn.go b/conn.go index a8b61547..22fa3de4 100644 --- a/conn.go +++ b/conn.go @@ -782,6 +782,11 @@ func ParseURI(uri string) (ConnConfig, error) { continue } + if k == "host" { + cp.Host = v[0] + continue + } + cp.RuntimeParams[k] = v[0] } if cp.Password == "" { diff --git a/conn_test.go b/conn_test.go index 763efd11..c0419d90 100644 --- a/conn_test.go +++ b/conn_test.go @@ -458,6 +458,19 @@ func TestParseURI(t *testing.T) { }, }, }, + { + url: "postgres:///foo?host=/tmp", + connParams: pgx.ConnConfig{ + Host: "/tmp", + Database: "foo", + TLSConfig: &tls.Config{ + InsecureSkipVerify: true, + }, + UseFallbackTLS: true, + FallbackTLSConfig: nil, + RuntimeParams: map[string]string{}, + }, + }, } for i, tt := range tests {