blob: eed5d838864d8371753aa64e66e68a5c832bb5cb (
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
43
44
45
46
47
48
49
|
type t
(** An SQL identifier (table or column name).
The type is abstract and implemented as a string: the only way to create a
value is {!of_string}, which validates the string. A [t] is therefore always
safe to embed in a quoted SQL identifier, and the query layer never
manipulates raw strings for table or column names. *)
exception Invalid of string
(** Raised by {!of_string} when the string is not a valid identifier. *)
val is_valid : string -> bool
(** [is_valid s] is [true] iff [s] is a non-empty sequence of letters, digits,
underscores or hyphens. In particular the double quote (which could break
out of a quoted identifier) and the dot (used internally to build the names
of the dedicated tables for multivalued fields) are rejected. *)
val of_string : string -> t
(** The only way to build an identifier. @raise Invalid if the string is not
valid. *)
val of_string_opt : string -> t option
(** [of_string_opt s] is [Some id] if [s] is valid, [None] otherwise. *)
val to_string : t -> string
(** The underlying string. *)
val id : t
(** The [id] column: primary key of every content table. *)
val parent : t
(** The [parent] column: foreign key to the parent content, present in
subcontent tables and in the dedicated tables of multivalued fields. *)
val target : t
(** The [target] column of the dedicated tables for multivalued fields. *)
val quote : t -> string
(** [quote id] is the SQL quoted form ["..."] of the identifier. *)
val dot : t -> t -> t
(** [dot a b] is the identifier ["a.b"], used for the dedicated tables of
multivalued fields. Both parts are already validated and contain no dot, so
the result is safe to quote as a single identifier. *)
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
val pp : Format.formatter -> t -> unit
|