package sqlgg
SQL Guided (code) Generator
Install
Dune Dependency
Authors
Maintainers
Sources
sqlgg-20200521.tar.gz
md5=b9e861726ce73364e303f0cc1d5ec049
sha256=b9bfd29dc5c880c324ed77ec333053317fd0806f5a64b573b5031ee7fc227deb
sha512=5f73a65b5cf5c17788a75f64b3def21a9d8e53b32a876a4fee4570317a20b48ca69879e9dadaa399d7e57f2e9d262850650bcb031fd90f6bf21abdf8d99ce1a6
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
(** 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 := []
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>