summaryrefslogtreecommitdiff
path: root/test/insert.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-19 11:32:16 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-19 11:32:16 +0100
commit8708171877054c98aad45079d85d4e699420f2fe (patch)
tree2e580e6891708b7b70d07f7bec03bd0a76ae171b /test/insert.ml
parente1bf7686f408b52a870d4ed4f3c565dbbcc3954f (diff)
Added fields in lists
Diffstat (limited to 'test/insert.ml')
-rw-r--r--test/insert.ml55
1 files changed, 25 insertions, 30 deletions
diff --git a/test/insert.ml b/test/insert.ml
index c30cde4..ee2c927 100644
--- a/test/insert.ml
+++ b/test/insert.ml
@@ -82,19 +82,17 @@ module Make (S : Decoders.Decode.S) = struct
( "reference",
match Model.Content.find_target content key with
| None -> S.fail "Not a feature"
- | Some (Model.Typ.List list) ->
+ | Some (Model.Reference.List _ as t) ->
(* A list is referenced by the id of one of its rows *)
+ let reference =
+ Model.Typ.MonoReference { t; constraints = None }
+ in
S.map
(fun v ->
- Lwt.return
- ( key,
- Model.Typ.(
- V
- ( MonoReference
- { t = Model.Typ.List list; constraints = None },
- Some (Int64.of_int v) )) ))
+ let value = Some (Int64.of_int v) in
+ Lwt.return (key, Model.Typ.V (reference, value)))
S.int
- | Some (Model.Typ.Content target_ref) ->
+ | Some (Model.Reference.Content target_ref as t) ->
let target = Model.Reference.get target_ref in
let* properties = self#properties target in
let sequence =
@@ -104,29 +102,24 @@ module Make (S : Decoders.Decode.S) = struct
insert_and_get_result db target properties
in
let reference =
- Model.Typ.{ t = Model.Typ.Content target_ref; constraints = None }
+ Model.Typ.MonoReference { t; constraints = None }
in
- Lwt.return
- ( key,
- Model.Typ.(
- V (Model.Typ.MonoReference reference, Some id)) )
+ Lwt.return (key, Model.Typ.V (reference, Some id))
in
S.succeed sequence );
( "references",
match Model.Content.find_target content key with
| None -> S.fail "Not a feature"
- | Some (Model.Typ.List list) ->
+ | Some (Model.Reference.List _ as t) ->
+ let multireference =
+ Model.Typ.MultiReference { t; constraints = None }
+ in
S.map
(fun ids ->
Lwt.return
- ( key,
- Model.Typ.(
- Seq
- ( MultiReference
- { t = Model.Typ.List list; constraints = None },
- List.to_seq ids )) ))
+ (key, Model.Typ.Seq (multireference, List.to_seq ids)))
(S.map (List.map ~f:Int64.of_int) (S.list S.int))
- | Some (Model.Typ.Content target_ref) ->
+ | Some (Model.Reference.Content target_ref as t) ->
let target = Model.Reference.get target_ref in
let* properties = self#values target in
let sequence =
@@ -134,14 +127,10 @@ module Make (S : Decoders.Decode.S) = struct
self#insert_and_return_references target properties
in
let reference =
- Model.Typ.{ t = Model.Typ.Content target_ref; constraints = None }
+ Model.Typ.MultiReference { t; constraints = None }
in
Lwt.return
- ( key,
- Model.Typ.(
- Seq
- ( Model.Typ.MultiReference reference,
- List.to_seq ids )) )
+ (key, Model.Typ.Seq (reference, List.to_seq ids))
in
S.succeed sequence );
@@ -167,7 +156,10 @@ module Make (S : Decoders.Decode.S) = struct
[
( "content",
fun v ->
- match (Configuration.Ast.get_content conf) (Model.Identifier.of_string key) with
+ match
+ (Configuration.Ast.get_content conf)
+ (Model.Identifier.of_string key)
+ with
| None -> Error (Decoders.Error.make "no content")
| Some subcontent ->
let values = self#values subcontent v in
@@ -195,7 +187,10 @@ module Make (S : Decoders.Decode.S) = struct
fun name ->
(* In this syntax, the content is supposed to follow the definition
and will never be None *)
- let content = Configuration.Ast.get_content conf (Model.Identifier.of_string name) |> Option.get in
+ let content =
+ Configuration.Ast.get_content conf (Model.Identifier.of_string name)
+ |> Option.get
+ in
let* properties =
S.field_opt_or ~default:(Lwt.return []) "values"
(self#values content)