Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically install PostgresPlugin in Jdbi3Builders#buildManagedJdbi when driver is Postgres #382

Closed
sleberknight opened this issue Oct 16, 2020 · 3 comments · Fixed by #383
Assignees
Labels
enhancement A request for change or improvement to an existing feature
Milestone

Comments

@sleberknight
Copy link
Member

It should first check to see if the caller passed a PostgresPlugin instance in the varargs. If it did not and the driver class is Postgres, it would be very nice for us to automatically do that.

Should there be a way to tell it not to do this automatically???

@sleberknight sleberknight added the enhancement A request for change or improvement to an existing feature label Oct 16, 2020
@sleberknight sleberknight added this to the 0.13.0 milestone Oct 16, 2020
@sleberknight
Copy link
Member Author

Since we use H2 sometimes in tests, we should also detect and install H2DatabasePlugin if the database URL is for an H2 database.

Currently only H2 and Postgres will be supported.

@sleberknight
Copy link
Member Author

sleberknight commented Oct 20, 2020

For now, we will not add a way to disable this auto-add functionality. We always want it, and I would imagine most people using H2 or Postgres would want the plugin to be installed as well.

@sleberknight
Copy link
Member Author

Also, since the H2 and Postgres plugins extend JdbiPlugin.Singleton we don't need to worry about checking if they supplied an H2 or Postgres plugin instance.

@sleberknight sleberknight self-assigned this Oct 20, 2020
sleberknight added a commit that referenced this issue Oct 20, 2020
* Add DatabaseType enum (package-private for now)
* Add Jdbi3Helpers (package-private for now)
* Add better documentation to top-level of Jdbi3Builders
* Renamed a few local vars and parameters in Jdbi3Builders from
  dataSource to managedDataSource for clarity
* Update Jdbi3Builders to install the H2 or Postgres JDBI plugin
  automatically if the database is detected as H2 or Postgres,
  respectively, from the JDBC database URL.
* Significantly de-mock the Jdbi3BuildersTest; the only remaining
  mock is the Dropwizard Environment. Use an in-memory H2 database to
  verify the real code, and that we can actually get a connection from
  the built Jdbi instance.

Fixes #382
chrisrohr pushed a commit that referenced this issue Oct 21, 2020
* Add DatabaseType enum (package-private for now)
* Add Jdbi3Helpers (package-private for now)
* Add better documentation to top-level of Jdbi3Builders
* Renamed a few local vars and parameters in Jdbi3Builders from
  dataSource to managedDataSource for clarity
* Update Jdbi3Builders to install the H2 or Postgres JDBI plugin
  automatically if the database is detected as H2 or Postgres,
  respectively, from the JDBC database URL.
* Significantly de-mock the Jdbi3BuildersTest; the only remaining
  mock is the Dropwizard Environment. Use an in-memory H2 database to
  verify the real code, and that we can actually get a connection from
  the built Jdbi instance.

Fixes #382
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A request for change or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant