[ANN] Caqti 1.8.0 and related news

I am happy to announce the second release of Caqti this year. The reason for the quick succession is partly an adjustment to the new API for request construction and partly that matchable error conditions did not make it into the previous release. You can see the full release notes below.

I would also like to thank OCaml Software Foundation for sponsoring my efforts on the Caqti project this year, also including most of the work that went into the previous release.

One feature in progress is a new driver based on the pure-OCaml pgx which should make it possible, with some additional changes to the way drivers are loaded, to target MirageOS. I am note sure if this can be done in a minor release or will require a Caqti 2 branch.

Release Notes

New features:

  • A matchable representation of common causes of errors on the database
    side is now available, with limitations. It focuses on conditions which
    seem most likely useful to handle. At the moment we lack extended error
    codes from SQLite3 needed to make the cause fully precise.

  • Expose the underlying error details from database client libraries.
    This is meant to be use as a last resort, and requires directly linking
    with the relevant drivers.

  • A second set of request construction operators ->., ->?, ->!, and
    ->* were introduced after experience with converting existing code.
    Given the parameter and result type they return a function which
    constructs a request directly from a query string. Avoiding the need to
    compose with @:- simplifies local opens and usage with List.map etc.

  • Environment variables are now expanded in the debug log when using the
    new request constructors introduced in 1.7.0.

  • A new ?tweaks_version connection parameter has been added to control
    when the client is ready to adapt to changes in database session
    parameters or other adjustments of the interaction with specific
    database systems. [More details available in the documentation.]

  • Enable foreign key constraint checks for SQLite3 starting at tweaks
    version 1.8.


  • Fixed debug logging to pass the correct driver info to the query
    callback instead of a dummy driver info which would cause a failure if


  • The --> operator was renamed to -->!, with a deprecated alias, for
    consistency with the new ->! operator.

  • The old convenience interface for creating requests has been deprecated
    in favour of the new infix operators and the new query template parser.

  • Documented-only deprecations of Caqti_sql_io, Caqti_lwt_sql_io, and
    Caqti_async_sql_io have been annotated.

Correction: Enabling of foreign key constraints for SQLite3 starts at tweaks version 1.8 (not 1.7). (Thanks @reynir for noticing!)


This link is broken.

Thanks for noticing. A new action pipeline for publishing docs broke in a way I don’t understand at the moment. I reverted to the old way, so it should work now.

1 Like

Thank you. I just switched a Dream project to the new infix syntax - it’s very nice.

Is the non-infix method of constructing requests gone now?

The old convenience functions have been deprecated and is scheduled for complete removal. A contributing reason to do so is that the template parser has some limitations, which was hard to lift without breaking backwards compatibility. The primitive Caqti_request.create function will remain, however, and can be used in combination with the Caqti_query module to construct requests without using the new operators.