blob: 322f4595a21e8a214e8986c4a279b7d384bb6109 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
let name = __FILE__
let description =
"Check the [Model.Identifier] module: validation of the names given as \
arguments, their quoted SQL form, the predefined columns and the composite \
names"
let speclist () = []
type t = string list
let pp : Format.formatter -> t -> unit =
Format.pp_print_list ~pp_sep:Format.pp_print_newline Format.pp_print_string
(** A valid name is printed in its quoted SQL form, an invalid one is
reported *)
let check : string -> string =
fun s ->
match Model.Identifier.of_string_opt s with
| Some id -> Model.Identifier.quote id
| None -> "invalid: \"" ^ s ^ "\""
let exec : string list -> t =
fun args ->
(* The anonymous arguments are collected in reverse order by the test
harness *)
match List.rev args with
| "check" :: names -> List.map check names
| "predefined" :: [] ->
[
"id = " ^ Model.Identifier.quote Model.Identifier.id;
"parent = " ^ Model.Identifier.quote Model.Identifier.parent;
"target = " ^ Model.Identifier.quote Model.Identifier.target;
]
| "dot" :: [ a; b ] ->
[
Model.Identifier.quote
(Model.Identifier.dot
(Model.Identifier.of_string a)
(Model.Identifier.of_string b));
]
| _ -> failwith "Invalid arguments"
|