opam: update
[sqlgg.git] / lib / stmt.ml
blob2616eb46eb6ed3b3124e86d93b0337aaee540505
1 (** Statement *)
3 open ExtLib
5 type insert_kind = Values | Assign [@@deriving show {with_path=false}]
7 (** inferred inserted values to complete sql statement *)
8 type inferred = (insert_kind * Sql.Schema.t) option [@@deriving show]
10 (** possible number of rows in query result *)
11 type cardinality = [`Zero_one | `One | `Nat] [@@deriving show]
13 let cardinality_to_string = show_cardinality
15 type kind = | Select of cardinality
16 | Insert of inferred * Sql.table_name
17 | Create of Sql.table_name
18 | CreateIndex of string
19 | Update of Sql.table_name option (** name for single-table UPDATEs *)
20 | Delete of Sql.table_name list
21 | Alter of Sql.table_name list
22 | Drop of Sql.table_name
23 | CreateRoutine of string
24 | Other
25 [@@deriving show {with_path=false}]
27 type category = DDL | DQL | DML | DCL | TCL | OTHER [@@deriving show {with_path=false}, enum]
29 let all_categories = List.init (max_category - min_category) (fun i -> Option.get @@ category_of_enum @@ min_category + i)
31 let category_of_stmt_kind = function
32 | Select _ -> DQL
33 | Insert _
34 | Update _
35 | Delete _ -> DML
36 | Create _
37 | CreateIndex _
38 | CreateRoutine _
39 | Alter _
40 | Drop _ -> DDL
41 | Other -> OTHER