Postgres defaults to unix socket with no host #229

Closes #229

When there's no host given in a postgres connection url, use the unix
domain default socket. Previously, the default was a localhost TCP
connection. This default behavior is more in line with standard postgres
clients out there, like psql.
This commit is contained in:
Matthew Wraith 2021-08-04 15:22:21 -07:00
parent 6243c2b9a9
commit 8175745cfe
2 changed files with 5 additions and 5 deletions

View file

@ -56,7 +56,7 @@ func TestConnectionString(t *testing.T) {
expected string
}{
// defaults
{"postgres:///foo", "postgres://localhost:5432/foo"},
{"postgres:///foo", "postgres://:5432/foo?host=%2Fvar%2Frun%2Fpostgresql"},
// support custom url params
{"postgres://bob:secret@myhost:1234/foo?bar=baz", "postgres://bob:secret@myhost:1234/foo?bar=baz"},
// support `host` and `port` via url params
@ -85,11 +85,11 @@ func TestConnectionArgsForDump(t *testing.T) {
expected []string
}{
// defaults
{"postgres:///foo", []string{"postgres://localhost:5432/foo"}},
{"postgres:///foo", []string{"postgres://:5432/foo?host=%2Fvar%2Frun%2Fpostgresql"}},
// support single schema
{"postgres:///foo?search_path=foo", []string{"--schema", "foo", "postgres://localhost:5432/foo"}},
{"postgres:///foo?search_path=foo", []string{"--schema", "foo", "postgres://:5432/foo?host=%2Fvar%2Frun%2Fpostgresql"}},
// support multiple schemas
{"postgres:///foo?search_path=foo,public", []string{"--schema", "foo", "--schema", "public", "postgres://localhost:5432/foo"}},
{"postgres:///foo?search_path=foo,public", []string{"--schema", "foo", "--schema", "public", "postgres://:5432/foo?host=%2Fvar%2Frun%2Fpostgresql"}},
}
for _, c := range cases {