summaryrefslogtreecommitdiff
path: root/lib/query/update.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-20 18:57:38 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-20 18:57:38 +0100
commit172a02b80d8dbdcfe09129d7fa76015bb5ec4d79 (patch)
treecb8613d53ce8051e39937ff05f8dc9b0fe80320e /lib/query/update.ml
parentfa4970bf1b74f3fa0b2f63cbd461d98c251dc0f0 (diff)
Refactoring
Diffstat (limited to 'lib/query/update.ml')
-rw-r--r--lib/query/update.ml51
1 files changed, 26 insertions, 25 deletions
diff --git a/lib/query/update.ml b/lib/query/update.ml
index ec1510b..5b53cb7 100644
--- a/lib/query/update.ml
+++ b/lib/query/update.ml
@@ -78,7 +78,8 @@ module ReferencesSet = Set.Make (Int64)
let update_mulivaluated_field :
Caqti_lwt.connection ->
Model.content ->
- (Model.Identifier.t * Model.target Model.Typ.multireference * int64 Seq.t) list ->
+ (Model.Identifier.t * Model.target Model.Typ.multireference * int64 Seq.t)
+ list ->
int64 ->
unit Lwt.t =
fun db content fields id ->
@@ -165,33 +166,33 @@ let q :
Seq.fold_left
(fun ((fields, references) as acc :
(Intf.t_type * (string * Value.value)) list
- * (Model.Identifier.t * Model.target Model.Typ.multireference * int64 Seq.t) list)
- field ->
+ * (Model.Identifier.t
+ * Model.target Model.Typ.multireference
+ * int64 Seq.t)
+ list) field ->
let name = Model.Field.name field in
let (Model.Field.T content_type) = Model.Field.type_ field in
let tt = Intf.TT { name; content_type } in
- let value = provider (Model.Identifier.to_string name) in
- match value with
- | Value.Data.Any d -> (
- match content_type with
- | Model.Typ.MultiReference _ -> (
- match d with
- | Value.Data.None -> acc
- | Value.Data.V (t, seq) -> (
- match
- ( Model.Typ.eq content_type t,
- Model.Typ.eq_ocaml content_type t )
- with
- | Some Type.Equal, Some Type.Equal ->
- (fields, (name, t, seq) :: references)
- | _ -> raise Encoder.TypeMismatch))
- | _ -> (
- match d with
- | Value.Data.None -> acc
- | Value.Data.V _ as dv ->
- ( (tt, (Model.Identifier.to_string name, Value.Data.any dv))
- :: fields,
- references ))))
+ let (Value.Data.Any d) = provider (Model.Identifier.to_string name) in
+ match content_type with
+ | Model.Typ.MultiReference _ -> (
+ match d with
+ | Value.Data.None -> acc
+ | Value.Data.V (t, seq) -> (
+ match
+ ( Model.Typ.eq content_type t,
+ Model.Typ.eq_ocaml content_type t )
+ with
+ | Some Type.Equal, Some Type.Equal ->
+ (fields, (name, t, seq) :: references)
+ | _ -> raise Encoder.TypeMismatch))
+ | _ -> (
+ match d with
+ | Value.Data.None -> acc
+ | Value.Data.V _ as dv ->
+ ( (tt, (Model.Identifier.to_string name, Value.Data.any dv))
+ :: fields,
+ references )))
([], [])
(Model.Content.fields content)
in