package mariadb

  1. Overview
  2. Docs

This module defines a database field retrieved by a query.

type t

The type of fields.

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

name field returns the field name of field.

val value : t -> value

value field returns the value associated with field.

val null_value : t -> bool

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

val 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.

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

Innovation. Community. Security.