Add host query parameter to support unix sockets

Currently there is no way to specify unix sockets in the connection
url. This patch adds a `host` query parameter that allows to set the path.
pull/473/head
Jörg Thalheim 2018-10-26 17:19:52 +01:00
parent 20eaa7963b
commit 3410ad9122
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
2 changed files with 18 additions and 0 deletions

View File

@ -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 == "" {

View File

@ -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 {