From 172a02b80d8dbdcfe09129d7fa76015bb5ec4d79 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 20 Nov 2026 18:57:38 +0100 Subject: Refactoring --- lib/query/update.ml | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'lib/query/update.ml') 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 -- cgit v1.2.3