12. Vendor Extensions

Version 0.2.0 introduces the doobie-contrib family of add-on libraries, which are published concurrently with the doobie release and provide support for functionality outside the JDBC specification. These can be added as needed:

libraryDependencies += "org.tpolecat" %% "doobie-contrib-XXX" % "0.2.0" // for some XXX

HikariCP Support

The doobie-contrib-hikari add-on provides a Transactor implementation backed by a HikariCP connection pool. Constructing an instance is an effect:

for {
  xa <- HikariTransactor[Task]("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "")
  _  <- longRunningProgram(xa) ensuring xa.shutdown
} yield ()

The returned instance is of type HikariTransactor, which provides a shutdown method (shown above) as well as a configure method that provides access to the underlying HikariDataSource. See the source for details.

H2 Support

The doobie-contrib-h2 add-on provides mappings for the following H2 types in the doobie.contrib.h2.h2types module.

PostgreSQL Support

The doobie-contrib-postgres add-on provides mappings for the following PostgreSQL types in the doobie.contrib.postgresql.pgtypes module.

A complete table of SQLSTATE values is provided in the doobie.contrib.postgresql.sqlstate module, and recovery combinators for each of these (onUniqueViolation for example) are provided in doobie.contrib.postgresql.syntax.

Specs2 Support

The doobie-contrib-specs2 add-on provides a mix-in trait for Specs2 tests that provides support for query validation. See the chapter on unit testing for more information.