diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-22 13:58:16 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-22 13:58:16 +0100 |
| commit | 056fcabaeec238a7aa927df39a90acea028b1aa0 (patch) | |
| tree | 3246359561eb2375e85da4537e05a083a1348467 /test | |
| parent | bc78bea63b7c75e8a9d222dc86fb75ed293a2242 (diff) | |
Added an option for loading a value content without the multivaluated fields (allow single query)main
Diffstat (limited to 'test')
| -rw-r--r-- | test/common.ml | 12 | ||||
| -rw-r--r-- | test/load.ml | 20 | ||||
| -rw-r--r-- | test/select.ml | 4 |
3 files changed, 26 insertions, 10 deletions
diff --git a/test/common.ml b/test/common.ml index 7b486b4..f3fe83a 100644 --- a/test/common.ml +++ b/test/common.ml @@ -205,14 +205,16 @@ let provider_for : Model.content -> Int64.t -> string -> Value.value = (List.of_seq (Model.Content.fields content)) row field_name -(** Render a [(named, data)] pair as a single line, whatever the field type *) +(** Render a [(name, typ), data] triple as a single line, whatever the field + type *) let show_field : 'db 'ocaml. - ('db, 'ocaml, Model.target) Model.Types.t Model.Types.named -> + Model.Identifier.t -> + ('db, 'ocaml, Model.target) Model.Types.t -> 'ocaml -> string = - fun named data -> - let name = Model.Identifier.to_string (Model.Types.name named) in + fun field_name typ data -> + let name = Model.Identifier.to_string field_name in let show : type db ocaml. (db, ocaml, Model.target) Model.Types.t -> ocaml -> string = fun typ data -> @@ -235,7 +237,7 @@ let show_field : ^ String.concat "," (List.map Int64.to_string targets) ^ "]" in - show (Model.Types.typ named) data + show typ data (** Read a configuration from the standard input and run [f] with a fresh in-memory database created from it *) diff --git a/test/load.ml b/test/load.ml index ebc4e15..e992e32 100644 --- a/test/load.ml +++ b/test/load.ml @@ -2,8 +2,9 @@ let name = __FILE__ let description = "Insert two rows of the given content, load them as values with [Value.load] \ - and print them with [Value.pp]. The configuration is read on the standard \ - input" + and print them with [Value.pp]; then load the first row again with \ + [~multivalued:false], which reads only the row itself. The configuration is \ + read on the standard input" let speclist () = [] @@ -30,7 +31,20 @@ let exec : string list -> t = function Lwt.return [ Format.sprintf "row %Ld:" id; Format.asprintf "%a" Value.pp v ] in + let load_one_partial id = + let* v = + Value.load db ~multivalued:false + (Model.Reference.of_content content) + id + in + Lwt.return + [ + Format.sprintf "row %Ld (without multivalued fields):" id; + Format.asprintf "%a" Value.pp v; + ] + in let* lines1 = load_one id1 in let* lines2 = load_one id2 in - Lwt.return (lines1 @ lines2)) + let* lines3 = load_one_partial id1 in + Lwt.return (lines1 @ lines2 @ lines3)) | _ -> failwith "Invalid arguments" diff --git a/test/select.ml b/test/select.ml index d185772..1ee6dc2 100644 --- a/test/select.ml +++ b/test/select.ml @@ -32,8 +32,8 @@ let exec : string list -> t = function Query.select db id content { f = - (fun (named, data) -> - acc := Common.show_field named data :: !acc); + (fun ((name, typ), data) -> + acc := Common.show_field name typ data :: !acc); } in Lwt.return (List.rev !acc) |
