package caqti
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d688bd22f6fde5be5a755900545fade0d5fdce6dbcb0b85770d02dad87c41e7c
md5=d18745a703da336054c0d27e78f8be8a
doc/caqti/Caqti_type/index.html
Module Caqti_type
Source
Type descriptors for fields and tuples.
Primitive Field Types
The following is normally only needed for drivers and to define new field types. Everything needed for common usage is covered in Row Types.
An extensible type describing primitive SQL types and types which can be converted to and from such types. When adding a new constructor, register the coding with Field.define_coding
if possible. Otherwise, the type will only work with drivers which handle it themselves. The shipped drivers only handle the constructors listed here.
Row Types
type _ t = private
Type descriptor for row types.
Note. The concrete representation of this type should be considered private, including pattern-matching usage; use the below functions for compatibility with future versions.
pp ppf t
prints a human presentation of t
on ppf
.
pp_ex ppf t
prints a human presentation of t
on ppf
.
Composite
The following provides constructors for narrow tuple types; to describe wider tuple types, use nested application.
A holding no fields. This is used to pass no parameters and as the result for queries which does not return any rows. It can also be nested in tuples, in which case it will not contribute to the total number of fields.
val custom :
encode:('a -> ('b, string) result) ->
decode:('b -> ('a, string) result) ->
'b t ->
'a t
custom ~encode ~decode rep
creates a custom type represented by rep
, where encode
is used to encode parameters into rep
and decode
is used to decode result rows from rep
.
Note. This should be considered experimental and may be revised or removed in a future version.
Singular
field ft
is a row of a single field of type ft
. This function can be used when adding new field types; use the below functions otherwise.
An UTF-8 string. The database should accept UTF-8 if non-ASCII characters are present.
An absolute time with driver-dependent precision. This corresponds to an SQL timestamp
type with UTC time zone.
A period of time. If the database lacks a dedicated representation, the integer number of seconds is used.