package sqlgg

  1. Overview
  2. Docs
SQL Guided (code) Generator

Install

Dune Dependency

Authors

Maintainers

Sources

sqlgg-20231201.tar.gz
md5=0841965b140612b9b1fb066cc21f88cb
sha256=7fbee5972b8fa0488bf31bb482101c93c328f67ceef3e95af165d554736d78fe
sha512=5d14e03e02f62c72c57cc574fd9f637e99118556a739af16d71e8813a8cbd8c330e48d69b9577ef2e9d0227aee9d85664cb4907f479927b7431e0475d954fa1a

doc/src/sqlgg.lib/stmt.ml.html

Source file stmt.ml

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
(** Statement *)

open ExtLib

type insert_kind = Values | Assign [@@deriving show {with_path=false}]

(** inferred inserted values to complete sql statement *)
type inferred = (insert_kind * Sql.Schema.t) option [@@deriving show]

(** possible number of rows in query result *)
type cardinality = [`Zero_one | `One | `Nat] [@@deriving show]

let cardinality_to_string = show_cardinality

type kind = | Select of cardinality
            | Insert of inferred * Sql.table_name
            | Create of Sql.table_name
            | CreateIndex of string
            | Update of Sql.table_name option (** name for single-table UPDATEs *)
            | Delete of Sql.table_name list
            | Alter of Sql.table_name list
            | Drop of Sql.table_name
            | CreateRoutine of string
            | Other
            [@@deriving show {with_path=false}]

type category = DDL | DQL | DML | DCL | TCL | OTHER [@@deriving show {with_path=false}, enum]

let all_categories = List.init (max_category - min_category) (fun i -> Option.get @@ category_of_enum @@ min_category + i)

let category_of_stmt_kind = function
| Select _ -> DQL
| Insert _
| Update _
| Delete _ -> DML
| Create _
| CreateIndex _
| CreateRoutine _
| Alter _
| Drop _ -> DDL
| Other -> OTHER
OCaml

Innovation. Community. Security.