package sqlgg
SQL Guided (code) Generator
Install
Dune Dependency
Authors
Maintainers
Sources
sqlgg-20231201.tar.gz
md5=0841965b140612b9b1fb066cc21f88cb
sha256=7fbee5972b8fa0488bf31bb482101c93c328f67ceef3e95af165d554736d78fe
sha512=5d14e03e02f62c72c57cc574fd9f637e99118556a739af16d71e8813a8cbd8c330e48d69b9577ef2e9d0227aee9d85664cb4907f479927b7431e0475d954fa1a
doc/src/sqlgg.lib/tables.ml.html
Source file tables.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
(** Global list of tables *) open Printf open ExtLib type table = Sql.table let all : table list ref = ref [] (** FIXME table names case sensitivity? *) (* NB compares with db name *) let by_name (name:Sql.table_name) = fun (n,_) -> n = name (** @raise Error when no such table *) let get_from tables name = try List.find (by_name name) tables with Not_found -> failwith (sprintf "no such table %s" (Sql.show_table_name name)) let get name = get_from !all name let get_schema name = snd (get name) let check name = ignore (get name) let add v = let (name,_) = v in match List.find_all (by_name name) !all with | [] -> all := v :: !all | _ -> failwith (sprintf "table %s already exists" (Sql.show_table_name name)) let drop name = check name; all := List.remove_if (by_name name) !all let rename oldname newname = let (_,t) = get oldname in add (newname,t); drop oldname let alter name f = check name; let alter_schema ((n,s) as table) = if n = name then name, f s else table in all := List.map alter_schema !all let alter_add name col pos = alter name (fun s -> Sql.Schema.add s col pos) let alter_drop name col = alter name (fun s -> Sql.Schema.drop s col) let alter_change name oldcol col pos = alter name (fun s -> Sql.Schema.change s oldcol col pos) let rename_column name oldcol newcol = alter name (fun s -> Sql.Schema.rename s oldcol newcol) let print ch tables = let out = IO.output_channel ch in List.iter (Sql.print_table out) tables; IO.flush out let print_all () = print stdout !all let print1 name = print stdout [get @@ Sql.make_table_name name] (* TODO allow db.name too *) let reset () = all := [] let all () = !all
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>