quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Support in DevServices for additional JDBC URL parameters #15579

Closed knutwannheden closed 3 years ago

knutwannheden commented 3 years ago

Description The DevServices feature currently doesn't yet support setting additional URL parameters for the created database. Some database (like Oracle and MySQL for example) allow specifying various parameters (e.g. time zone) as JDBC URL parameters. Currently the JDBC URL will be constructed by Testcontainers, so to specify URL parameters the Dev Service would have to call org.testcontainers.containers.JdbcDatabaseContainer#withUrlParam().

Currently DevServicesDatasourceProvider#startDatabase() declares a parameter Map<String, String> additionalProperties. I am however not quite sure about the intended purpose of this parameter. While Testcontainers currently doesn't support specifying parameters (which would be passed to java.sql.Driver#connect(String, Properties)), this isn't really necessary either, because Dev Services doesn't delegate the Connection creation to Testcontainers, only the JDBC URL creation.

Implementation ideas Possibly the Map<String, String> additionalProperties parameter could be (renamed and) repurposed. Or if I have misunderstood its purpose, possibly a new parameter could be introduced which would allow specifying additional JDBC URL parameters.

knutwannheden commented 3 years ago

I don't know if it would make sense to parse the JDBC URL config property for the datasource and extract the URL parameters from that or whether there should be another dedicated DevServices config property for this. I am thinking it might be nice if the URL parameters would be extracted by default and could be overridden if necessary.

famod commented 3 years ago

/cc @stuartwdouglas

@gsmet maybe "DevServices" should trigger some labels, e.g. area/devmode and area/testing?

stuartwdouglas commented 3 years ago

There needs to be a dedicated property for this, if devservices is in use then there is no URL to parse (as the presence of a URL will stop devservices starting)

knutwannheden commented 3 years ago

There needs to be a dedicated property for this, if devservices is in use then there is no URL to parse (as the presence of a URL will stop devservices starting)

I see. I hadn't quite understood yet that this is how devservices is activated. Thanks for the clarification.

knutwannheden commented 3 years ago

As commented on the PR, I believe the implementation for MSSQL needs some minor adjustment.