amacneil / amacneil/dbmate

$PGHOST & $PGPORT are not respected.

Ouverte
#492 3 commentaires 3 réactions 0 personnes assignées Voir sur GitHub
feature request
Langage dominant
Go
Étoiles
7.4k
Forks
379
Merge moyen
6 min
PR mergées (30 j)
1

Description

Given the following environment variables:

- `$DATABASE_URL`: `postgres://`
- `$PGHOST`: `some-host`
- `$PGPORT`: `8888`
- `$PGDATABASE`: `some-db`

I believe it'd be a logical assumption, for callers of `dbmate`, to expect that (`dbmate`) would attempt, in any such case, to connect to `some-db`, via dialing `some-host` on port `8888`, while retaining `postgres://` as the value of its `url.URL`.

However, what happens instead is that `dbmate` tries to connect via `/var/run/postgresql/.s.PGSQL.5432` (or the equivalent platform default, as defined in [`connectionString`](https://github.com/amacneil/dbmate/blob/26dd5ea397d7e4aa7da960805cf59023b82f313e/pkg/driver/postgres/postgres.go#L39C1-L39C1)), disregarding any [Postgres-related environment variable](https://www.postgresql.org/docs/current/libpq-envars.html) that may be defined in its environment, and replaces the empty tokens (`host`, `port`, etc) with hard-coded values.

I believe that `lib/pg`, the underlying driver, supports these environment variables when considering each connection string / DSN.

Is this behavior intended? If not, happy to take a stab at a patch for it.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.