Releases: paurkedal/ocaml-caqti
2.1.2
CHANGES:
Fixes:
- Improve error reporting when failing to load a driver (#115).
- Fix validation of dead connection in postgresql driver (#119 by Sam
Tombury). - Tolerate exceptions from pool resource allocators (#116 reported by Ryan
Moore). - Fix install script for the caqti.opam package to work with caqti.plugin.
- Fix the announced license exception in the caqti-driver-pgx package.
Dependency updates:
- Update to
tls
>= 1.0.0 for caqti-mirage (#120 by Hannes Mehnert). - Update tls-eio to >= 0.17.4 for caqti-tls-eio (to eliminate a hack).
- Update
async_kernel
to >= v0.17.0 andtcpip
to >= 8.1.0 (due to
resolving deprecations for future compatibility).
2.1.1
2.1.0
CHANGES:
-
There is now TLS support for PGX. The networking code (for PGX) was
revised in the process, in particular the EIO variant is now buffered,
which improves performarce. TLS implemantions are shipped as separate
packages (caqti-tls*
) butcaqti-tls-async
,caqti-tls-eio
, and
caqti-tls-lwt
should be considered experimental and will be omitted
from the OPAM release for now. On the other hand,caqti-mirage
now
ships with built-in TLS support for PGX. -
Connect functions now accept an optional configuration. For the time
being, this is used for TLS parameters and for the optional
tweaks_version
argument, which is still available for backwards
compatibility. -
The newly introduced
Caqti_query.qprintf
and associated formatters
have been moved to a separate moduleCaqti_query_fmt
(#108), to limit
clashes when used in local open, and since the formatters were nominally
underqualified. -
Constants of any field type can now be embedded in queries using the new
Caqti_query.V
constructor and associated shortcuts. This allows
taking advantage of driver-specific encoders, e.g. to correctly convert
aPtime.Span.t
to the representation expected by the target database
system. -
Equality with type unification evidence is now available for
Caqti_type.t
andCaqti_type.Field.t
. The equality type introduced
for the purpose is compatible withType.eq
from OCaml 5.1, but will
not be aliased yet. This required a backwards incompatible adjustment
of theCaqti_type.Product
constructor. -
Added tuples type constructors with arity up to 12.
-
Added multi-statement parser (
Caqti_query.angstrom_list_parser
)
intended for loading SQL schema files. -
The new
caqti.plugin
sublibrary is a drop-in replacement for the
caqti-dynload
package. It is based on thedune-site.plugin
library.
Please try it and report back if there are issues. -
Some updates to external dependencies, esp. we are now at EIO 0.12+.
-
Fixed lacking details in error messages related to driver load failures.
-
Fixed uncaught exceptions for PGX (#113).
2.0.1
2.0.0
CHANGES:
New features:
-
Added driver based on the pure-OCaml PGX library (#38). However, due to
lack of TLS support it is not suitable for production, unless you have a
dedicated secure network. -
Added support for MirageOS. This only works for the PGX driver, since
the other drivers link against external C libraries. -
Added experimental support for Eio, both pure-OCaml and Unix. The
former supports PGX while the latter supports all drivers. -
Implemented single-row mode for PostgreSQL (#24), but while this avoids
uncontrolled memory consumption when a large number of rows is returned,
it is a lot less efficient. -
A new pool connection parameter
?max_idle_age
provides removal
resources from pools which have been unused for the given period. -
Printf-style function
Caqti_query.qprintf
for dynamic queries
(GPR#103, Basile Clément). -
Added general-purpose product type to provide functionality covering
both product and custom types. -
Added new tuple types
t3
, ...,t8
based on the new product type and
deprecatedtup2
,tup3
,tup4
which are now aliases for these.
Breaking changes:
-
The minimal OCaml requirement is now 4.08.0.
-
The connection functions previously found in
caqti-lwt
has been moved
into a sublibrarycaqti-lwt.unix
as part of the addition of
caqti-mirage
, whereas shared functionality remains incaqti-lwt
.
The LWT connection function is therefore now found inCaqti_lwt_unix
. -
Removed all deprecated functionality and a few unintended or
undocumented definitions like the typeCaqti_blocking.future
and
Caqti_driver_info.describe_has_typed_*
. -
Reworked the driver API to accommodate the addition of the PGX driver
and MirageOS and Eio support, and to avoid exposting internal interfaces
in the main library. These modules are now found in the sublibraries
caqti.platform
andcaqti.platform.unix
, depending on their external
depnedencies. They are not meant for use by applications, though this
might not have fully clear previously. -
Removed constructors Custom, Unit, Tup2, Tup3, Tup4 from
Caqti_type.t
.
They were private but could in prinicle be matched against. -
The extensibility of
Caqti_type.Field.t
has been dropped along with
the associated functions for registering conversions. This means that
there are no custom field types any more, only custom row types. The
purpose of custom field types where to support non-standard types for
3rd party drivers; we should coordinate additions to the core type
instead if needed. -
According to the above point, the
caqti-type-calendar
is reimplemented
as a row type, which means theCdate
andCtime
constructors are
gone. -
There are adjustments for the pretty printer for types. (The context is
assumed to start at the lowest precedence, meaning parentheses around
lowest-precedence expressions are dropped. Also,redacted
is shown
with suffix notation, allowing us to remove one precedence level.) -
Moved pool tuning parameters into a configuration object.
Fixes:
-
Fixed a missing
Preemptive.detach
call forto_stream
for Sqlite3. -
Incorrect error reporting related to type conversions were discovered by
exhaustiveness checks when making field types non-extensible.
Other:
-
The documentation of
call
now makes clear that the result must be
retrieved in order to make sure the request is performed. This is made
relevant by the addition of the PGX driver where request and retrieval
are fused. -
Customized the top-level index and some other documentation work.
Removal of private modules from the main library should also help to
make the documentation more accessible. -
Added a benchmark to measure row decoding performance.
-
Improved decoding performance by partially applying the type descriptor.
1.9.1
CHANGES:
This release only updates the caqti-driver-postgresql package, with the
following fixes:
-
PostgreSQL expects "=" in query values to be URI-encoded (#95).
-
The validation logic for PostgreSQL was missing a call to consume
available input, meaning that broken pooled connections were reused.
This release was sponsored by the OCaml Software Foundation.
1.9.0
CHANGES:
New features:
-
Allow unquoted semicolons in query strings in the new API. There are
corner cases where it is needed, as reported in issue #87, and a parser
which rejects semicolons are still available for loading schema files
statement by statement. -
Add support for MySQL and MariaDB configuration files, as a solution to
issue #86. -
Add a limit to the number of times a database connection is reused when
pooling connections (#94). Thanks to Peter Mondlock for investigating
resource usage server side motivating this addition. -
Provide access to the raw SQLite3 connection handle for the purpose of
defining custom functions (#56).
Fixes:
-
Add missing dune dependency on unix (GPR#85 by David Allsopp).
-
Documentation fixes (GPR#82, GPR#83, GPR#84 by Reynir Björnsson,
GPR#88 by Jonathan Duarte, and GPR#92 by Jim Tittsler).
Deprecations:
Caqti_type.field
was deprecated in favour ofCaqti_type.Field.t
.
Other:
- Replace deprecated core_kernel dependency with core.
This release was sponsored by the OCaml Software Foundation.
1.8.0
CHANGES:
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 withList.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. -
Enable foreign key constraint checks for SQLite3 starting at tweaks
version 1.8.
Fixes:
- 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
unsupported.
Deprecations:
-
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.
This release was sponsored by the OCaml Software Foundation.
1.7.0
CHANGES:
New features:
-
Added a new query-string parser based on Angstrom. Its main advantage
is that it can be used stand-alone e.g. to load SQL schemas from files
split into individual statements which can be sent to the database. -
Support passing a query environment to the connect and pool construction
functions. This avoids using globals to modify the environment and
facilitates e.g. targeting different database schemas with different
connetions or connection pools. -
A new
Caqti_query.E
case was added to support the two above cases.
This is a breaking change, but hopefully does not break existing code.
The exception (not countingmodule type of
) would be if the
constructors are aliased along with an alias of the type. On the other
hand, pattern matching should be compatible since the new constructor is
only emitted by newly introduced functions. -
Added a module
Caqti_request.Infix
providing a new high-level API for
constructing requests. It uses two-stage combinators, first to apply
type arguments then to apply the query string. Apart from allowing
nicer looking code, this solves the problem of switching to a the query
string parser while maintaining backwards compatibility. -
Added
set_statement_timeout
to connection modules, used to set query
timeout. It is only supported for PostgreSQL and MariaDB. (#74) -
Added
with_transaction
function to connection modules. This is just
fail-safed wrapper aroundstart
,commit
, androllback
.
Fixes:
-
Fixed delayed recovery of connection pools after loosing connections to
PostgreSQL. Due to a missing call to consume inputs, the pool validator
did not discover that a connection was lost before it was attempted
reused. -
Improved resilience against exceptions and monadic errors in callbacks
and fixed in-use checking. -
Changed Sqlite3 driver to use non-linear parameters and improve error
reporting when the wrong number of arguments are received (#77 & GPR#79
Reynir Björnsson).
Other changes:
-
The Caqti license now uses the LGPL-3.0 Linking Exception instead of a
rephrasing of the OCaml LGPL Linking Exception which was written for
LGPL-2.1. -
Improved documentation, pretty-printing, logging, and exception details.
-
The test suite has been switched to use Alcotest; not without some
struggle due to the use of test harness and argument-dependent test
suite, but the result seems like a clear improvement.
This release was sponsored by the OCaml Software Foundation.
v1.6.0
CHANGES:
- Set the time zone of PostgreSQL connections to UTC to mitigate an
undesirable implicit conversion to the local time zone fortimestamp
.
This issue was exposed by the specification of field types introduced in
version 1.4.0. Earlier versions worked as expected, if only accidentally,
since the time zone is ignored when a string is converted to a
timestamp
. While this change makestimestamp
more usable again for
storing UTC time stamps, I strongly recommend usingtimestamp with time zone
since it's interpretation is unambiguous. The API reference is now
updated with details about how theptime
OCaml type is mapped for
different database systems. - Drop specification of OCaml
string
as SQLtext
for PostgreSQL. This is
due to issues with implicit conversions and function overloading when the
desired type on the SQL side ischar
,varchar
, orjsonb
. - Add
Caqti_type.redact
to protect sensitive information from being
logged. - Only log parameters if
$CAQTI_DEBUG_PARAM
is set to "true
". - When logging requests, show underlying values for custom types.
- Reject multi-row response in
find_opt
implementation for sqlite3. - Tolerate Lwt promise rejections in
Pool.use
.