summaryrefslogtreecommitdiff
path: root/test/insert.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-19 09:57:49 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-19 09:57:49 +0100
commite1bf7686f408b52a870d4ed4f3c565dbbcc3954f (patch)
treeee7e156032cc0c43ca10879051e64c3dfeab1515 /test/insert.ml
parenta9628fda0fc027c54b5ed5313a0c41731d79e41f (diff)
Management of lists in the settings
Diffstat (limited to 'test/insert.ml')
-rw-r--r--test/insert.ml31
1 files changed, 27 insertions, 4 deletions
diff --git a/test/insert.ml b/test/insert.ml
index b5da90d..c30cde4 100644
--- a/test/insert.ml
+++ b/test/insert.ml
@@ -82,7 +82,19 @@ module Make (S : Decoders.Decode.S) = struct
( "reference",
match Model.Content.find_target content key with
| None -> S.fail "Not a feature"
- | Some target_ref ->
+ | Some (Model.Typ.List list) ->
+ (* A list is referenced by the id of one of its rows *)
+ S.map
+ (fun v ->
+ Lwt.return
+ ( key,
+ Model.Typ.(
+ V
+ ( MonoReference
+ { t = Model.Typ.List list; constraints = None },
+ Some (Int64.of_int v) )) ))
+ S.int
+ | Some (Model.Typ.Content target_ref) ->
let target = Model.Reference.get target_ref in
let* properties = self#properties target in
let sequence =
@@ -92,7 +104,7 @@ module Make (S : Decoders.Decode.S) = struct
insert_and_get_result db target properties
in
let reference =
- Model.Typ.{ t = target_ref; constraints = None }
+ Model.Typ.{ t = Model.Typ.Content target_ref; constraints = None }
in
Lwt.return
( key,
@@ -103,7 +115,18 @@ module Make (S : Decoders.Decode.S) = struct
( "references",
match Model.Content.find_target content key with
| None -> S.fail "Not a feature"
- | Some target_ref ->
+ | Some (Model.Typ.List list) ->
+ S.map
+ (fun ids ->
+ Lwt.return
+ ( key,
+ Model.Typ.(
+ Seq
+ ( MultiReference
+ { t = Model.Typ.List list; constraints = None },
+ List.to_seq ids )) ))
+ (S.map (List.map ~f:Int64.of_int) (S.list S.int))
+ | Some (Model.Typ.Content target_ref) ->
let target = Model.Reference.get target_ref in
let* properties = self#values target in
let sequence =
@@ -111,7 +134,7 @@ module Make (S : Decoders.Decode.S) = struct
self#insert_and_return_references target properties
in
let reference =
- Model.Typ.{ t = target_ref; constraints = None }
+ Model.Typ.{ t = Model.Typ.Content target_ref; constraints = None }
in
Lwt.return
( key,