package mariadb

  1. Overview
  2. Docs

Module S.FieldSource

This module defines a database field retrieved by a query.

Sourcetype t

The type of fields.

Sourcetype value = [
  1. | `Null
  2. | `Int of int
  3. | `Float of float
  4. | `String of string
  5. | `Bytes of bytes
  6. | `Time of Time.t
]
Sourceval name : t -> string

name field returns the field name of field.

Sourceval value : t -> value

value field returns the value associated with field.

Sourceval null_value : t -> bool

null_value field returns true if the value associated with field is NULL.

Sourceval can_be_null : t -> bool

can_be_null field returns true if values of field can assume the NULL value (i.e. the table definition does not specify NOT NULL for this field.

Value retrieval functions

The functions below simplify the unwrapping of OCaml values from fields. They raise Failure if the field is not of the expected type, but this should not be a problem as the type of a field is in all likelyhood known in advance by database users.

Sourceval int : t -> int
Sourceval float : t -> float
Sourceval string : t -> string
Sourceval bytes : t -> bytes
Sourceval time : t -> Time.t
Sourceval int_opt : t -> int option
Sourceval float_opt : t -> float option
Sourceval string_opt : t -> string option
Sourceval bytes_opt : t -> bytes option
Sourceval time_opt : t -> Time.t option
OCaml

Innovation. Community. Security.