Description
The problem
Postgres supports a bunch of stuff in connection strings:
https://www.postgresql.org/docs/9.5/static/libpq-connect.html#LIBPQ-CONNSTRING
However, ConnectionParameters
, pg-connection-string
and pg.Pool
's config seem to only be aware about certain limited subset (like ssl
, fallback_app_name
and others). Doesn't seem practical to validate those in node, since server will already reject invalid config (I think).
Usecase
Instead of running a bunch of set X to Y
after connecting to postgres on every client, I'd like to specify some session settings on connection string. In particular, I'd like to reproduce the following psql
invocation from the node:
psql postgresql://?options=-c%20timezone%3DEurope/Moscow
Solution
Probably parse the whole query string and pass everything we found in it to the server. Not sure how connection flow works, and how to use those parsed params.
Looks like there are a bunch of places need to be change in order to achieve this. Not sure if these are all of them:
pg-connection-string
'sparse
function;pg.Client
;pg.ConnectionParameters
;pg.Pool
's constructor- anything else?
I would be happy to PR this, but I'm not sure where to start. Any tips?
As a sidenote, would be neat to support this stuff: psql options="-c\ timezone=Europe/Moscow"
.