Module Caqti_template.VersionSource

Opaque version strings with comparison.

This version number module is intended for dispatching on details about an SQL intepreter or other relevant aspects of a relational database system. The only constructor is private, instead the Infix module provides direct comparison to strings for ideomatic usage in the query-returning callback of request templates.

Some care is needed to match ranges of versions correctly:

Sourcetype t
Sourceval is_known : t -> bool

Tests whether a version from the database server is available.

Sourceval compare : t -> t -> int

Compares two versions lexicographically group-by-group and component-by-component, using common conventions for comparing version numbers:

  • Groups of components are separated by '-'.
  • Components are separated by '.'.
  • Continuous sequences of digits are compared numerically, i.e. after skipping leading zeros, longer such sequences compare after shorter ones.
  • '~' compares before anything else, including the empty suffix.

The ordering subject to change if we should encounter problematic differences with versioning schemes used by supported database systems.

Sourceval equal : t -> t -> bool

equal x y is equivalent to compare x y = 0.

Sourcemodule Infix : sig ... end

Asymmetric infix oparator for testing version ranges. The first argument is a version number, typically obtained from the server_version fields of Dialect.t, and the second argument is a string representation of the version to compare against.

Sourceval pp : Format.formatter -> t -> unit