package macaque

  1. Overview
  2. Docs
type untyped
type 'a writable
type non_writable
type nullable
type non_nullable
type 'n nul_witness
val nullable_witness : nullable nul_witness
val non_nullable_witness : non_nullable nul_witness
class type 't type_info = object ... end
class type numeric_t = object ... end
class type unit_t = object ... end
class type bool_t = object ... end
class type int16_t = object ... end
class type int32_t = object ... end
class type int64_t = object ... end
class type float_t = object ... end
class type string_t = object ... end
class type bytea_t = object ... end
class type time_t = object ... end
class type date_t = object ... end
class type timestamp_t = object ... end
class type timestamptz_t = object ... end
class type interval_t = object ... end
class type int32_array_t = object ... end
class type 'row row_t = object ... end
type 't type_info_only = < t : 't type_info >
type +'a t

values

val untyped_t : 'a t -> untyped t
type 'phant binary_op = 'a t -> 'b t -> 'c t constraint 'a = < t : 'in_t ; nul : 'n.. > constraint 'b = < t : 'in_t ; nul : 'n.. > constraint 'c = < t : 'out_t ; nul : 'n > constraint 'phant = < in_t : 'in_t ; out_t : 'out_t ; nul : 'n ; a : 'a ; b : 'b >

type synonyms for convenience

type 'a nullable_data = < get : unit ; t : 'a ; nul : nullable > t
type 'a non_nullable_data = < get : unit ; t : 'a ; nul : non_nullable > t
type +'a unsafe

unsafe

val unsafe : 'a -> 'a unsafe
type +'a sql_type

types

val untyped_type : 'a sql_type -> untyped sql_type
val recover_type : 'a sql_type -> untyped sql_type unsafe -> 'a sql_type
val get_type : < t : 't ; nul : 'nul.. > t -> < t : 't ; nul : 'nul ; get : unit > sql_type
val cast : < t : 't ; nul : 'nul.. > as 'a t -> < t : 't ; nul : 'nul.. > sql_type -> 'a t
type 'a result_parser = (string array * int Stdlib.ref) -> 'a

parsers

type 'a record_parser = untyped sql_type Sql_base.tuple -> 'a result_parser
val get : < get : _ ; nul : non_nullable ; t : 't type_info > t -> 't

access functions

val getn : < get : _ ; nul : nullable ; t : 't type_info > t -> 't option
val parse : 'a sql_type -> 'a t result_parser

parse function

type (+'a, 'w) view

views

val untyped_view : (_, 'w) view -> (untyped, untyped) view
val field : < t : 'a row_t ; nul : non_nullable.. > t -> string list unsafe -> (row:'a -> < t : 't ; nul : 'n.. > t) unsafe -> < t : 't ; nul : 'n > t
val default : (_, 'def writable) view -> string unsafe -> (default_fields:'def -> < t : 't ; nul : 'n.. > t) unsafe -> < t : 't ; nul : 'n > t
val row : string unsafe -> ('a, _) view -> < t : < typ : 'a > ; nul : non_nullable > t
val tuple : untyped t Sql_base.tuple unsafe -> (tuple:'tup -> untyped t Sql_base.tuple) unsafe -> 'tup record_parser unsafe -> < t : < typ : 'tup > ; nul : non_nullable > t
val if_then_else : < t : bool_t.. > t -> < in_t : 't ; out_t : 't.. > binary_op
val match_null : < t : 't ; nul : nullable.. > t -> < t : 'res_t ; nul : 'res_n.. > t -> (< t : 't ; nul : non_nullable.. > t -> < t : 'res_t ; nul : 'res_n.. > t) -> < t : 'res_t ; nul : 'res_n > t
type +'a result constraint 'a = < .. >

select and view building

val simple_select : < t : 'a row_t.. > t -> 'a result
type where = < t : bool_t > t list
type order =
  1. | Asc
  2. | Desc
val view : 'a result -> ?order_by:(untyped t * order) list -> ?limit:< t : numeric_t.. > t -> ?offset:< t : numeric_t.. > t -> from -> where -> ('a, non_writable) view
type grouped_row

group by and accumulators

val grouped_row : grouped_row
type +'a group
type +'a accum
val accum : 'a t -> 'a accum
val group_of_accum : 'a accum -> 'a group
val group : < t : 'const row_t.. > t -> < t : 'res row_t.. > t -> 'res result
val table : untyped sql_type Sql_base.tuple -> (row:'row -> untyped t Sql_base.tuple) unsafe -> 'row record_parser -> (string option * string) -> ('def * untyped t Sql_base.tuple) -> ('row, 'def writable) view

tables

module Table_type : sig ... end

standard SQL field types (in pa_descr, ie. <:table< .. >>)

type +'a query

final query building

val select : ('a, _) view -> 'a list query
val insert : ('a, _ writable) view -> ('a, _) view -> unit query
val delete : ('a, _ writable) view -> string unsafe -> from -> where -> unit query
val update : ('a, _ writable) view -> string unsafe -> 'b t -> bool unsafe -> from -> where -> unit query
val value : < t : 't ; nul : 'nul.. > t -> < t : 't ; nul : 'nul ; get : unit > t query
val sql_of_query : _ query -> string

query printing

val sql_of_view : (_, _) view -> string
val handle_query_results : 'a query -> string array list unsafe -> 'a

handle result from PGOCaml call

module Value : sig ... end

standard SQL value injections (usable from user code, in pa_macaque value antiquotations)

type 'a sequence

sequence creation operators (usable from user code, in pa_descr sequence expressions)

module Sequence : sig ... end
module Op : sig ... end

standard SQL operators (usable from user code, in pa_comp expressions)

module View : sig ... end

standard view injections (in pa_comp, view antiquotations)

module ViewOp : sig ... end

standard view operators

val break : _ t -> Sql_internals.value
val break_view : (_, _) view -> Sql_internals.view
OCaml

Innovation. Community. Security.