prisma / quaint

SQL Query AST and Visitor for Rust
Apache License 2.0
583 stars 61 forks source link

PostgreSQL: Support `options` connection string parameter #338

Closed janpio closed 2 years ago

janpio commented 2 years ago

PostgreSQL supports an options parameter for connection strings:

Specifies command-line options to send to the server at connection start. For example, setting this to -c geqo=off sets the session's value of the geqo parameter to off. Spaces within this string are considered to separate command-line arguments, unless escaped with a backslash (); write \ to represent a literal backslash.

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-OPTIONS

Cockroach Cloud for example uses that to submit the cluster name when a connection is created: ...?options=--cluster%3D{{CLUSTER_NAME}}

Our PostgreSQL driver Tokio-Postgres also support this parameter:

options - Command line options used to configure the server.

https://docs.rs/tokio-postgres/latest/tokio_postgres/config/struct.Config.html

Right now it seems we are filtering this value out of the connection string, or at least not forwarding it to Tokio-Postgres: https://prisma.github.io/quaint/src/quaint/connector/postgres.rs.html#267

It would be great if we could enable Prisma to use the options parameter in PostgreSQL connection strings.