Caqti_platform.Request_utils
SourceInternal request-related utilities.
type linear_param =
| Linear_param : int * 'a Caqti_template.Field_type.t * 'a -> linear_param
linear_param_length templ
is the number of linear parameters expected by a query represented by templ
.
val linear_param_order :
?subst:Caqti_template.Query.subst ->
Caqti_template.Query.t ->
int list list * linear_param list
linear_param_order templ
describes the parameter bindings expected for templ
after linearizing parameters and lifting quoted strings out of the query:
i
is a list of linear parameter positions to which to bind the i
th incoming parameter.Linear_param (i, t, v)
where i
is the position of the linear parameter taking the place of a embedded value, t
is its field type, and v
is the value itself.All positions are zero-based.
val linear_query_string :
?subst:Caqti_template.Query.subst ->
Caqti_template.Query.t ->
string
linear_query_string templ
is templ
where "?"
is substituted for parameters and quoted strings.
val raise_encode_missing :
uri:Uri.t ->
field_type:'a Caqti_template.Field_type.t ->
unit ->
'counit
val raise_encode_rejected :
uri:Uri.t ->
typ:'a Caqti_template.Row_type.t ->
Caqti_error.msg ->
'counit
val raise_encode_failed :
uri:Uri.t ->
typ:'a Caqti_template.Row_type.t ->
Caqti_error.msg ->
'counit
val raise_decode_missing :
uri:Uri.t ->
field_type:'a Caqti_template.Field_type.t ->
unit ->
'counit
val raise_decode_rejected :
uri:Uri.t ->
typ:'a Caqti_template.Row_type.t ->
Caqti_error.msg ->
'counit
type 'a field_encoder = {
write_value : 'b. uri:Uri.t ->
'b Caqti_template.Field_type.t ->
'b ->
'a ->
'a;
write_null : 'b. uri:Uri.t -> 'b Caqti_template.Field_type.t -> 'a -> 'a;
} constraint 'e = [> `Encode_rejected of Caqti_error.coding_error ]
val encode_param :
uri:Uri.t ->
'a field_encoder ->
'b Caqti_template.Row_type.t ->
'b ->
'a ->
'a
type 'a field_decoder = {
read_value : 'b. uri:Uri.t -> 'b Caqti_template.Field_type.t -> 'a -> 'b * 'a;
skip_null : int -> 'a -> 'a option;
} constraint 'e = [> `Decode_rejected of Caqti_error.coding_error ]
val decode_row :
uri:Uri.t ->
'a field_decoder ->
'b Caqti_template.Row_type.t ->
'a ->
'b * 'a