package caqti

  1. Overview
  2. Docs
Abstraction over multiple database libraries

Install

Dune Dependency

Authors

Maintainers

Sources

caqti-0.9.0.tbz
sha256=4c84a16d983d0fed2786f536a3fa4d8fa113b8b30b4deea4a74772582d5489b2
md5=42a2e2d3b73d7fbaecc618549aad2865

doc/caqti/Caqti_type/index.html

Module Caqti_typeSource

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.

Sourcetype 'a field = ..

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.

Sourcetype field +=
  1. | Bool : bool field
  2. | Int : int field
  3. | Int32 : int32 field
  4. | Int64 : int64 field
  5. | Float : float field
  6. | String : string field
  7. | Octets : string field
  8. | Pdate : Ptime.t field
  9. | Ptime : Ptime.t field

Primitive field types handled by the shipped drivers.

Sourcemodule Field : sig ... end

Facilities for extending and using primitive field types.

Row Types

Sourcetype _ t = private
  1. | Unit : unit t
  2. | Field : 'a field -> 'a t
  3. | Option : 'a t -> 'a option t
  4. | Tup2 : 'a t * 'b t -> ('a * 'b) t
  5. | Tup3 : 'a t * 'b t * 'c t -> ('a * 'b * 'c) t
  6. | Tup4 : 'a t * 'b t * 'c t * 'd t -> ('a * 'b * 'c * 'd) t
  7. | Custom : {
    1. rep : 'b t;
    2. encode : 'a -> ('b, string) result;
    3. decode : 'b -> ('a, string) result;
    } -> 'a t

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.

Sourcetype ex =
  1. | Ex : 'a t -> ex

t with existentially wrapped static type.

Sourceval length : 'a t -> int

length t is the number of fields used to represent t.

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

pp ppf t prints a human presentation of t on ppf.

Sourceval pp_ex : Format.formatter -> ex -> unit

pp_ex ppf t prints a human presentation of t on ppf.

Sourceval show : 'a t -> string

show t is a human presentation of t.

Composite

Sourceval option : 'a t -> 'a option t
Sourceval unit : unit t

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.

Sourceval tup2 : 'a t -> 'b t -> ('a * 'b) t

Creates a pair type.

Sourceval tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t

Creates a 3-tuple type.

Sourceval tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t

Creates a 4-tuple type.

Sourceval 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

Sourceval field : 'a field -> 'a t

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.

Sourceval bool : bool t

A boolean.

Sourceval int : int t

An integer.

Sourceval int32 : int32 t

A 32 bit integer.

Sourceval int64 : int64 t

A 64 bit integer.

Sourceval float : float t

A float.

Sourceval string : string t

An UTF-8 string. The database should accept UTF-8 if non-ASCII characters are present.

Sourceval octets : string t

A binary string.

Sourceval pdate : Ptime.t t

A date. This corresponds to the SQL date type.

Sourceval ptime : Ptime.t t

An absolute time with driver-dependent precision. This corresponds to an SQL timestamp type with UTC time zone.

OCaml

Innovation. Community. Security.