vertx-sql-client icon indicating copy to clipboard operation
vertx-sql-client copied to clipboard

[PostgreSQL] lowercasing when parsing URL prohibits configuring generic parameters

Open gvogel-hh opened this issue 4 years ago • 4 comments

Version

Which version(s) did you encounter this bug ? 3.9.0

Context

I tried to configure an idle timeout with PgConnectOptions.fromUri() using ?user=xyz&idleTimeout=60

The code looks like it should work since all extra parameters are put into the JSON and passed to the base classes, among them TCPSSLOptions, but all keys are initially lowercased in PgConnectionUriParser, and TCPSSLOptions expects "idleTimeout".

Do you have a reproducer?

PgConnectOptions.fromUri("postgresql://host/db?user=xyz&idleTimeout=60").getIdleTimeout()

gvogel-hh avatar May 27 '20 23:05 gvogel-hh

This is not a bug, the doc says only a few connection props are supported and lists them.

If this enhancement is implemented, not only we have to avoid putting the lower-cased prop name in the json object, but we also need to find a way to determine the type of the property (currently it would work with strings only).

tsegismont avatar Sep 01 '20 13:09 tsegismont

faced similar problem while setting idle_in_transaction_session_timeout and statement_timeout by url parameters.
Looking at PG docs https://www.postgresql.org/docs/11/runtime-config-client.html it seems there are a lot of useful parameters could be set using url, but not much are supported at the moment by pg-client.
as a work around I've set idle_in_transaction_session_timeout manually to the PgConnectOptions (like this PgConnectOptions.fromUri("...").addProperty("idle_in_transaction_session_timeout", timeout))

robotmrv avatar Jul 05 '21 08:07 robotmrv

I think that most properties should be generically supported and not related to the TCP options at all.

currently the code do:

          default:
            configuration.put(key, value);
            break;

instead it should simply

            properties.put(key, value);

and that's it

vietj avatar Jul 05 '21 10:07 vietj

I want to create a Pool by URI to decouple database type from code. But I found the following URI cannot set the fields in SqlConnectOptions because cachePreparedStatements was converted to lower case in PgConnectionUriParser.

postgresql://postgres:[email protected]:5432/bmsql?cachePreparedStatements=true

TeslaCN avatar Sep 06 '22 12:09 TeslaCN