Commit 2330e5ce85c4b5038492b783f97fcc9161cdf6d4
1 parent
b306048e
[+] add some files to support PostgreSQL (in early stage, not yet functional)
[*] really add declared default value into default row type
Showing
17 changed files
with
1278 additions
and
657 deletions
Show diff stats
hayamiki_generator.1.19.aproj
| ... | ... | @@ -72,6 +72,16 @@ |
| 72 | 72 | <Compile Include="hayamiki_lib\view\hk_filter.anubis" /> |
| 73 | 73 | <Compile Include="hayamiki_lib\view\jqgrid.anubis" /> |
| 74 | 74 | <Compile Include="hayamiki_lib\view\load_vtm.anubis" /> |
| 75 | + <Compile Include="hayamiki_lib\view\types\hk_editor.anubis" /> | |
| 76 | + <Compile Include="hayamiki_lib\view\types\hk_editor_table.anubis" /> | |
| 77 | + <Compile Include="hayamiki_lib\view\types\hk_filter.anubis" /> | |
| 78 | + <Compile Include="hayamiki_lib\view\types\hk_fk_view.anubis" /> | |
| 79 | + <Compile Include="hayamiki_lib\view\types\hk_form.anubis" /> | |
| 80 | + <Compile Include="hayamiki_lib\view\types\hk_form_entry.anubis" /> | |
| 81 | + <Compile Include="hayamiki_lib\view\types\hk_form_tab.anubis" /> | |
| 82 | + <Compile Include="hayamiki_lib\view\types\hk_form_table.anubis" /> | |
| 83 | + <Compile Include="hayamiki_lib\view\types\hk_view.anubis" /> | |
| 84 | + <Compile Include="hayamiki_lib\view\types\hk_viewer.anubis" /> | |
| 75 | 85 | <Compile Include="hayamiki_lib\view\view_apps_renderer.anubis" /> |
| 76 | 86 | <Compile Include="hayamiki_lib\view\view_editor_renderer.anubis" /> |
| 77 | 87 | <Compile Include="hayamiki_lib\view\view_rows_import.anubis" /> |
| ... | ... | @@ -101,6 +111,7 @@ |
| 101 | 111 | <Compile Include="library\data_base\metaSQL_test.anubis" /> |
| 102 | 112 | <Compile Include="library\data_base\metaSQL_web.anubis" /> |
| 103 | 113 | <Compile Include="library\data_base\mysql_client.anubis" /> |
| 114 | + <Compile Include="library\data_base\postgresql.anubis" /> | |
| 104 | 115 | <Compile Include="library\data_base\postgres_client.anubis" /> |
| 105 | 116 | <Compile Include="library\data_base\postgres_graphic_interface.anubis" /> |
| 106 | 117 | <Compile Include="library\data_base\read_csv.anubis" /> |
| ... | ... | @@ -431,11 +442,13 @@ |
| 431 | 442 | <Compile Include="library\xml\basic_xml_parser.anubis" /> |
| 432 | 443 | <Compile Include="library\xml\xml_parser.apg.anubis" /> |
| 433 | 444 | <Compile Include="src\app\app_loggers.anubis" /> |
| 445 | + <Compile Include="src\app\app_types.anubis" /> | |
| 434 | 446 | <Compile Include="src\app\app_version.anubis" /> |
| 435 | 447 | <Compile Include="src\check.anubis" /> |
| 436 | 448 | <Compile Include="src\generation\choices_selector.anubis" /> |
| 437 | 449 | <Compile Include="src\generation\columns.anubis" /> |
| 438 | 450 | <Compile Include="src\generation\create_table.anubis" /> |
| 451 | + <Compile Include="src\generation\create_table.anubis" /> | |
| 439 | 452 | <Compile Include="src\generation\cxm_lib_menu.anubis" /> |
| 440 | 453 | <Compile Include="src\generation\densaku.anubis" /> |
| 441 | 454 | <Compile Include="src\generation\edit_view_list_form.anubis" /> |
| ... | ... | @@ -450,6 +463,10 @@ |
| 450 | 463 | <Compile Include="src\generation\icons.anubis" /> |
| 451 | 464 | <Compile Include="src\generation\json.anubis" /> |
| 452 | 465 | <Compile Include="src\generation\model.anubis" /> |
| 466 | + <Compile Include="src\generation\PostgreSQL\create_table.anubis" /> | |
| 467 | + <Compile Include="src\generation\PostgreSQL\SQL_get_all.anubis" /> | |
| 468 | + <Compile Include="src\generation\SQLite\create_table.anubis" /> | |
| 469 | + <Compile Include="src\generation\SQLite\SQL_get_all.anubis" /> | |
| 453 | 470 | <Compile Include="src\generation\SQL_get_all.anubis" /> |
| 454 | 471 | <Compile Include="src\generation\SQL_get_count.anubis" /> |
| 455 | 472 | <Compile Include="src\generation\to_current.anubis" /> |
| ... | ... | @@ -857,6 +874,8 @@ |
| 857 | 874 | <Folder Include="src" /> |
| 858 | 875 | <Folder Include="src\generation" /> |
| 859 | 876 | <Folder Include="src\app" /> |
| 877 | + <Folder Include="src\generation\PostgreSQL" /> | |
| 878 | + <Folder Include="src\generation\SQLite" /> | |
| 860 | 879 | <Folder Include="src\utils" /> |
| 861 | 880 | <Folder Include="xlib" /> |
| 862 | 881 | <Folder Include="xlib\asterisk" /> | ... | ... |
hayamiki_lib @ 65fb857035b
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 14/05/2025 | |
| 5 | + * Time: 17:23 | |
| 6 | + * © David RENÉ | |
| 7 | + */ | |
| 8 | + | |
| 9 | + | |
| 10 | +public type HK_DB_engine: | |
| 11 | + sqlite3, | |
| 12 | + postgresql | |
| 13 | +. | |
| 14 | + | |
| 15 | +public define HK_DB_engine | |
| 16 | + to_HK_DB_engine | |
| 17 | + ( | |
| 18 | + String engine_string | |
| 19 | + )= | |
| 20 | + if engine_string = "sqlite3" then | |
| 21 | + sqlite3 | |
| 22 | + else if engine_string = "postgresql" then | |
| 23 | + postgresql | |
| 24 | + else | |
| 25 | + sqlite3 | |
| 26 | +. | |
| 27 | + | |
| 28 | +public define String | |
| 29 | + to_String | |
| 30 | + ( | |
| 31 | + HK_DB_engine hk_db_engine | |
| 32 | + )= | |
| 33 | + if hk_db_engine is | |
| 34 | + { | |
| 35 | + sqlite3 then "Sqlite 3" | |
| 36 | + postgresql then "PostgreSQL" | |
| 37 | + } | |
| 38 | +. | ... | ... |
src/app/app_version.anubis
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 17/05/2025 | |
| 5 | + * Time: 23:52 | |
| 6 | + * © David RENÉ | |
| 7 | + */ | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | +read hayamiki_lib/types/hayamiki.anubis | |
| 12 | +read tools/streams.anubis | |
| 13 | +read ../columns.anubis | |
| 14 | + | |
| 15 | +public define Maybe(One) | |
| 16 | + generate_postgresql_get_all | |
| 17 | + ( | |
| 18 | + Stream stream, | |
| 19 | + HK_Table table | |
| 20 | + )= | |
| 21 | + since table is hk_table(name, short_name, model, _), | |
| 22 | + since model is hk_model(columns, constraints, _), | |
| 23 | + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 24 | + | |
| 25 | + //generate the type of the table that contain all components | |
| 26 | + if write_string(stream, | |
| 27 | + "\n\n"+ | |
| 28 | + "public define List("+type_name+")\n"+ | |
| 29 | + " _get_all_"+name+"\n"+ | |
| 30 | + " (\n"+ | |
| 31 | + " One -> DbRow table_cursor,\n"+ | |
| 32 | + " List("+type_name+") so_far\n"+ | |
| 33 | + " ) =\n"+ | |
| 34 | + " if extract_"+name+"(table_cursor) is\n"+ | |
| 35 | + " {\n"+ | |
| 36 | + " failure then reverse(so_far),\n"+ | |
| 37 | + " success(data) then _get_all_"+name+"(table_cursor, [data . so_far])\n"+ | |
| 38 | + " }.\n"+ | |
| 39 | + "\n\n" | |
| 40 | + //SQL query | |
| 41 | +// "public define List("+type_name+")\n"+ | |
| 42 | +// " get_all_"+name+"\n"+ | |
| 43 | +// " (\n"+ | |
| 44 | +// " SQLite3DataBase db,\n"+ | |
| 45 | +// " )=\n"+ | |
| 46 | +// " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ | |
| 47 | +// " {\n"+ | |
| 48 | +// " error(_) then [],\n"+ | |
| 49 | +// " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ | |
| 50 | +// " }.\n"+ | |
| 51 | +// "\n\n" | |
| 52 | + ) is //end of the function | |
| 53 | + { | |
| 54 | + failure then println("can't write generate_get_all "+type_name); failure, | |
| 55 | + success(_) then success(unique) | |
| 56 | + }. | |
| 57 | + | |
| 58 | +//public define JsonMember | |
| 59 | +// get_component | |
| 60 | +// ( | |
| 61 | +// String component_name, | |
| 62 | +// Crm_price_level type | |
| 63 | +// )= | |
| 64 | +// if component_name = "id" then json_member(component_name, json_int(type.id)) | |
| 65 | +// else if component_name = "code" then json_member(component_name, json_string(type.code)) | |
| 66 | +// else if component_name = "label" then json_member(component_name, json_string(type.label)) | |
| 67 | +// else if component_name = "active" then json_member(component_name, json_bool(type.active)) | |
| 68 | +// else if component_name = "module" then json_member(component_name, json_string(type.module)) | |
| 69 | +// else json_member(component_name, json_null) | |
| 70 | +//. | |
| 71 | + | |
| 72 | +public define Maybe(One) | |
| 73 | + generate_postgresql_get_all_with_clause | |
| 74 | + ( | |
| 75 | + Stream stream, | |
| 76 | + HK_Table table | |
| 77 | + )= | |
| 78 | + since table is hk_table(name, short_name, model, _), | |
| 79 | + since model is hk_model(columns, constraints, _), | |
| 80 | + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 81 | + | |
| 82 | + //generate the type of the table that contain all components | |
| 83 | + if write_string(stream, | |
| 84 | + //SQL query | |
| 85 | + "public define Maybe(One -> BdRow)\n"+ | |
| 86 | + " get_all_"+name+"_by_clause\n"+ | |
| 87 | + " (\n"+ | |
| 88 | + " DataBase db,\n"+ | |
| 89 | + " String clause\n"+ | |
| 90 | + " )=\n"+ | |
| 91 | + " with final_clause = if clause = \"\" then\n"+ | |
| 92 | + " \"\"\n"+ | |
| 93 | + " else\n"+ | |
| 94 | + " \"WHERE \"+clause,\n"+ | |
| 95 | + "\n"+ | |
| 96 | + " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+" \"+final_clause+\";\", [], \"get_all_"+name+"_by_clause\") is\n"+ | |
| 97 | + " {\n"+ | |
| 98 | + " error(_) then failure,\n"+ | |
| 99 | + " ok(_, cursor, _) then success(cursor)\n"+ | |
| 100 | + " }\n"+ | |
| 101 | + ".\n"+ | |
| 102 | + "\n"+ | |
| 103 | + "public define List("+type_name+")\n"+ | |
| 104 | + " get_all_"+name+"_by_clause_to_list_type\n"+ | |
| 105 | + " (\n"+ | |
| 106 | + " DataBase db,\n"+ | |
| 107 | + " String clause\n"+ | |
| 108 | + " )=\n"+ | |
| 109 | + " if get_all_"+name+"_by_clause(db, clause) is\n"+ | |
| 110 | + " {\n"+ | |
| 111 | + " failure then [],\n"+ | |
| 112 | + " success(cursor) then _get_all_"+name+"(cursor, [])\n"+ | |
| 113 | + " }\n"+ | |
| 114 | + ".\n"+ | |
| 115 | + | |
| 116 | +//"public define List(JsonValue)\n"+ | |
| 117 | +//" _get_all_"+name+"_to_json\n"+ | |
| 118 | +//" (\n"+ | |
| 119 | +//" SQLite3DataBase db,\n"+ | |
| 120 | +//" List(((Int -> SQLite3Datum) -> JsonMember)) extractors,\n"+ | |
| 121 | +//" One -> SQLite3Row table_cursor,\n"+ | |
| 122 | +//" List(JsonValue) so_far\n"+ | |
| 123 | +//" ) =\n"+ | |
| 124 | +//" if extract_"+name+"_cursor_to_json(db, extractors, table_cursor) is\n"+ | |
| 125 | +//" {\n"+ | |
| 126 | +//" failure then reverse(so_far),\n"+ | |
| 127 | +//" success(data) then _get_all_"+name+"_to_json(db, extractors, table_cursor, [data . so_far])\n"+ | |
| 128 | +//" }\n"+ | |
| 129 | +//".\n"+ | |
| 130 | + | |
| 131 | +"public define JsonValue\n"+ | |
| 132 | +" get_all_"+name+"_by_clause_to_json\n"+ | |
| 133 | +" (\n"+ | |
| 134 | +" DataBase db,\n"+ | |
| 135 | +" List(String) columns,\n"+ | |
| 136 | +" Bool resolve_fk,\n"+ | |
| 137 | +" HK_Referer referer,\n"+ | |
| 138 | +" String filter,\n"+ | |
| 139 | +" String order_by\n"+ | |
| 140 | +" )=\n"+ | |
| 141 | +" with ref_clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n"+ | |
| 142 | +" with final_columns = if length(columns) = 0 then [\"id\". "+name+"_columns] else columns,\n\n"+ | |
| 143 | +" with _and_ = if length(ref_clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+ | |
| 144 | +" if get_all_"+name+"_by_clause(db, ref_clause+_and_+filter+\" \"+order_by) is\n"+ | |
| 145 | +" {\n"+ | |
| 146 | +" failure then json_array([]),\n"+ | |
| 147 | +" success(cursor) then\n"+ | |
| 148 | +" json_array(\n"+ | |
| 149 | +//" _get_all_"+name+"_to_json(db, make_"+name+"_json_extractor(db, final_columns, resolve_fk), cursor, [])\n"+ | |
| 150 | +" get_all_to_json(db, make_"+name+"_json_extractor(db, final_columns, resolve_fk), cursor, [])\n"+ | |
| 151 | +" )\n"+ | |
| 152 | +" }\n"+ | |
| 153 | +".\n" | |
| 154 | + ) is //end of the function | |
| 155 | + { | |
| 156 | + failure then println("can't write generate_get_all "+type_name); failure, | |
| 157 | + success(_) then success(unique) | |
| 158 | + } | |
| 159 | +. | ... | ... |
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 14/05/2025 | |
| 5 | + * Time: 22:11 | |
| 6 | + * © David RENÉ | |
| 7 | + | |
| 8 | + Hayamiki is Copyright © 2016-2025 by David RENÉ | |
| 9 | + All rights reserved. | |
| 10 | + | |
| 11 | + Redistribution and use in source and binary forms, with or without modification, | |
| 12 | + are permitted provided that the following conditions are met: | |
| 13 | + | |
| 14 | + 1. Redistributions of source code must retain the above copyright notice, | |
| 15 | + this list of conditions and the following disclaimer. | |
| 16 | + | |
| 17 | + 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 18 | + this list of conditions and the following disclaimer in the documentation | |
| 19 | + and/or other materials provided with the distribution. | |
| 20 | + | |
| 21 | + THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
| 22 | + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | |
| 23 | + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 24 | + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | |
| 25 | + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 26 | + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 27 | + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 28 | + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 29 | + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | + POSSIBILITY OF SUCH DAMAGE. | |
| 31 | +*/ | |
| 32 | + | |
| 33 | + | |
| 34 | +read hayamiki_lib/types/hayamiki.anubis | |
| 35 | +read tools/basis.anubis | |
| 36 | +read tools/int.anubis | |
| 37 | +read system/string.anubis | |
| 38 | +read system/files.anubis | |
| 39 | +read data_base/db_tools.anubis | |
| 40 | +read data_base/postgresql.anubis | |
| 41 | +read tools/streams.anubis | |
| 42 | +read tools/ISO-8601.anubis | |
| 43 | + | |
| 44 | +read ../fields.anubis | |
| 45 | +read ../columns.anubis | |
| 46 | + | |
| 47 | +read ../../utils/utils.anubis | |
| 48 | + | |
| 49 | +define String | |
| 50 | + create_table_generate_one_column | |
| 51 | + ( | |
| 52 | + HK_Model_Column column, | |
| 53 | + Int fill_size | |
| 54 | + )= | |
| 55 | + since column is hk_column(name, col_type, attributes, _), | |
| 56 | + | |
| 57 | + fill(escaped_quoted_postgresql_reserved_keyword(name), fill_size)+ to_postgresql_SQL_CREATE(col_type, attributes, name) | |
| 58 | + . | |
| 59 | + | |
| 60 | +define String | |
| 61 | + create_table_generate_columns | |
| 62 | + ( | |
| 63 | + List(HK_Model_Column) columns, | |
| 64 | + String indent | |
| 65 | + )= | |
| 66 | + //get the longest column name size, to be able to make formatting according to column name. | |
| 67 | + with column_max_size = max(columns), | |
| 68 | + join(",\n"+indent, map((HK_Model_Column column) |-> create_table_generate_one_column(column, column_max_size+1), columns)) | |
| 69 | + . | |
| 70 | + | |
| 71 | +define String | |
| 72 | + to_String | |
| 73 | + ( | |
| 74 | + HK_On_Conflict on_conflict | |
| 75 | + )= | |
| 76 | + if on_conflict is | |
| 77 | + { | |
| 78 | + rollback then "ROLLBACK", | |
| 79 | + abort then "ABORT", | |
| 80 | + fail then "FAIL", | |
| 81 | + ignore then "IGNORE", | |
| 82 | + replace then "REPLACE" | |
| 83 | + } | |
| 84 | +. | |
| 85 | + | |
| 86 | +define String | |
| 87 | + create_table_generate_one_constraint | |
| 88 | + ( | |
| 89 | + HK_Constraint constraint, | |
| 90 | + String indent | |
| 91 | + )= | |
| 92 | + since constraint is unique(_name, columns, _on_conflict), | |
| 93 | + with name = if _name = "" then "" else "CONSTRAINT "+_name+" ", | |
| 94 | + ",\n"+ | |
| 95 | + indent+name+"UNIQUE (\n"+ | |
| 96 | + indent+indent+join(",\n"+indent+indent, escaped_quoted_postgresql_reserved_keyword(columns))+"\n"+ | |
| 97 | + indent+")\n"+ | |
| 98 | + indent+"ON CONFLICT "+to_String(_on_conflict) | |
| 99 | +. | |
| 100 | + | |
| 101 | +define String | |
| 102 | + create_table_generate_constraints | |
| 103 | + ( | |
| 104 | + List(HK_Constraint) constraints, | |
| 105 | + String indent | |
| 106 | + )= | |
| 107 | + join(",\n"+indent, map((HK_Constraint constraint) |-> create_table_generate_one_constraint(constraint, indent), constraints)) | |
| 108 | +. | |
| 109 | + | |
| 110 | +define String | |
| 111 | + create_table_generate_one_table | |
| 112 | + ( | |
| 113 | + HK_Table table | |
| 114 | + )= | |
| 115 | + since table is hk_table(name, short_name, model, display), | |
| 116 | + since model is hk_model( columns, constraints, _), | |
| 117 | + | |
| 118 | + "\n"+ | |
| 119 | + " // "+to_upper(name)+"\n"+ | |
| 120 | + "public define String create_table_"+name+" =\n"+ | |
| 121 | + "\"CREATE TABLE "+name+" (\n"+ | |
| 122 | + //columns | |
| 123 | + " "+create_table_generate_columns([hk_column("id", p_key) . columns], " ")+ | |
| 124 | + create_table_generate_constraints(constraints, " ")+ | |
| 125 | + "\n)\".\n" | |
| 126 | + . | |
| 127 | + | |
| 128 | +define String | |
| 129 | + create_table_generate_all_tables | |
| 130 | + ( | |
| 131 | + List(HK_App) apps, // | |
| 132 | + List(HK_Table) tables, //list of the table model description | |
| 133 | + String so_far | |
| 134 | + )= | |
| 135 | + if tables is | |
| 136 | + { | |
| 137 | + [] then //no more table to generate | |
| 138 | + if apps is | |
| 139 | + { | |
| 140 | + [] then //no more apps to generate | |
| 141 | + so_far, //return the all create table generated so far | |
| 142 | + [app. t_apps] then //another app available | |
| 143 | + since app is hk_app(name, _, _, app_tables), | |
| 144 | + create_table_generate_all_tables(t_apps, app_tables, so_far + "\n /************ TABLES for Application '"+name+"' ***************/") | |
| 145 | + }, | |
| 146 | + | |
| 147 | + [table . t] then | |
| 148 | + //generate the current table "CREATE TABLE" | |
| 149 | + create_table_generate_all_tables(apps, t, so_far + create_table_generate_one_table(table)) | |
| 150 | + }. | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | +define String | |
| 155 | + generate_all_tables_list | |
| 156 | + ( | |
| 157 | + List(HK_App) apps, | |
| 158 | +// List(HK_Table) tables, //list of the table model description | |
| 159 | + String indent | |
| 160 | + )= | |
| 161 | + //calculate then longest table name and add 4 for enclosed quote + coma + final space | |
| 162 | + //hence we can make a beautiful formatting | |
| 163 | + with max_space = longest_table_name_size(apps, 0) + 4, | |
| 164 | + join(",\n", | |
| 165 | + map_append((HK_App app) |-> since app is hk_app(_, _, _, tables), | |
| 166 | + map((HK_Table table) |-> indent+"table("+fill("\""+table.name+"\",", max_space)+"create_table_"+table.name+")", tables), apps)). | |
| 167 | + | |
| 168 | +public define Maybe(One) | |
| 169 | + generate_postgresql_create_table | |
| 170 | + ( | |
| 171 | + String app_name, | |
| 172 | + List(HK_App) apps, //list of the table model description | |
| 173 | + String dest_dir, | |
| 174 | + String version, | |
| 175 | + String _sha1 | |
| 176 | + )= | |
| 177 | + | |
| 178 | + with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language | |
| 179 | + | |
| 180 | + with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", | |
| 181 | + with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", | |
| 182 | + //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis", | |
| 183 | + //create all necessary directories if doesn't exist. | |
| 184 | + make_directories(file_name); | |
| 185 | + | |
| 186 | + //create script file name as new file. Previous file with same name will be erased | |
| 187 | + if file(create_file_name, new) is | |
| 188 | + { | |
| 189 | + failure then println("Can't create script "+create_file_name);failure, | |
| 190 | + success(fd_script) then | |
| 191 | + with script_stream = make_stream(fd_script), | |
| 192 | + //write into script file the generated create table | |
| 193 | + if write_string(script_stream, | |
| 194 | +"/* | |
| 195 | + * Created by 早見木 (Hayamiki). | |
| 196 | + * Date: "+_Int_to_ISO_8601_date(now)+" | |
| 197 | + * Time: "+_Int_to_ISO_8601_time(now)+" | |
| 198 | + */ | |
| 199 | + | |
| 200 | +read system/logger.anubis | |
| 201 | +read xlib/database/migration_common.anubis | |
| 202 | +read data_base/sqlite_foreign_key.anubis | |
| 203 | +read data_base/db_types.anubis\n"+ | |
| 204 | + //call the generation of all tables | |
| 205 | + create_table_generate_all_tables(apps, [], "")+ | |
| 206 | + //TODO make indexes | |
| 207 | + "\npublic define List(String) db_indexes = [].\n"+ | |
| 208 | + "// ///////////////////////////////\n"+ | |
| 209 | + "// Foreign keys \n"+ | |
| 210 | + "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n\n\n | |
| 211 | +define String _version = \""+version+"\". | |
| 212 | + | |
| 213 | +public define Maybe(One) | |
| 214 | + create_v"+version_str+"_tables | |
| 215 | + ( | |
| 216 | + DataBase db, | |
| 217 | + (LogLevel, String) -> One logger | |
| 218 | + )= | |
| 219 | + logger(logInfo, \"DB migration create_v"+version_str+"_tables\"); | |
| 220 | + if drop_all_triggers(db, logger) is failure then | |
| 221 | + logger(logError, \"DB migration create_v"+version_str+"_tables: drop_all_triggers error\"); | |
| 222 | + failure | |
| 223 | + else | |
| 224 | + | |
| 225 | + with tables = (List(DbTable)) [ | |
| 226 | +"+generate_all_tables_list(apps, " ")+" | |
| 227 | + ], | |
| 228 | + if create_tables(db, logger, tables, _version) is | |
| 229 | + { | |
| 230 | + failure then | |
| 231 | + logger(logError, \"DB migration create_v"+version_str+"_tables: create_tables error\"); | |
| 232 | + failure, | |
| 233 | + success(_) then | |
| 234 | + if make_foreign_keys(db, logger, db_relations, _version) is failure then failure else | |
| 235 | + success(unique) | |
| 236 | + } | |
| 237 | +. | |
| 238 | + | |
| 239 | +public define DB_Version db_model_version = db_version(\""+version+"\", \""+_sha1+"\"). | |
| 240 | +\n\n" | |
| 241 | + | |
| 242 | + ) is | |
| 243 | + { | |
| 244 | + failure then println ("Can't generate script "+create_file_name);failure, | |
| 245 | + success(_) then | |
| 246 | + //create file with create table management (alter_table, etc...) | |
| 247 | + if file_exists(file_name) then | |
| 248 | + success(println("Skip creation of "+file_name+" because it's already exists and preventing to erase custom migration stuff")) | |
| 249 | + else | |
| 250 | + if file(file_name, new) is | |
| 251 | + { | |
| 252 | + failure then println("can't create file "+file_name);failure, | |
| 253 | + success(fd) then | |
| 254 | + with stream = make_stream(fd), | |
| 255 | + write_string(stream, | |
| 256 | +"/* | |
| 257 | + * Created by 早見木 (Hayamiki). | |
| 258 | + * Date: "+_Int_to_ISO_8601_date(now)+" | |
| 259 | + * Time: "+_Int_to_ISO_8601_time(now)+" | |
| 260 | + */ | |
| 261 | + * | |
| 262 | +read tools/basis.anubis | |
| 263 | +read system/files.anubis | |
| 264 | +read system/logger.anubis | |
| 265 | +read data_base/db_tools.anubis | |
| 266 | + | |
| 267 | +read xlib/database/db_utils.anubis | |
| 268 | +read xlib/database/migration_common.anubis | |
| 269 | +read xlib/database/migration.anubis | |
| 270 | +read data_base/alter_table.anubis | |
| 271 | + | |
| 272 | +read types/app_types.anubis | |
| 273 | +read app/app_constants.anubis | |
| 274 | +read app/app_loggers.anubis | |
| 275 | + | |
| 276 | +read database/generated/migration/to_"+version+"_create.anubis | |
| 277 | + | |
| 278 | +define String _version = \""+version+"\". | |
| 279 | + | |
| 280 | +public define Maybe(One) | |
| 281 | + create_v"+version_str+"_indexes | |
| 282 | + ( | |
| 283 | + DataBase db, | |
| 284 | + (LogLevel, String) -> One logger | |
| 285 | + )= | |
| 286 | + logger(logInfo, \"DB migration create_v"+version_str+"_indexes\"); | |
| 287 | + if create_indexes(db, logger, db_indexes, _version) is failure then failure else | |
| 288 | + success(unique) | |
| 289 | + . | |
| 290 | + | |
| 291 | +define Maybe(One) | |
| 292 | + to_v"+version_str+"_pre | |
| 293 | + ( | |
| 294 | + DataBase db, | |
| 295 | + (LogLevel, String) -> One logger | |
| 296 | + )= | |
| 297 | + logger(logInfo, \"DB migration to_v"+version_str+"_pre\"); | |
| 298 | + success(unique) | |
| 299 | +. | |
| 300 | + | |
| 301 | +define Maybe(One) | |
| 302 | + to_v"+version_str+"_post | |
| 303 | + ( | |
| 304 | + DataBase db, | |
| 305 | + (LogLevel, String) -> One logger | |
| 306 | + )= | |
| 307 | + logger(logInfo, \"DB migration to_v"+version_str+"_post\"); | |
| 308 | + success(unique) | |
| 309 | +. | |
| 310 | + | |
| 311 | +public define Maybe(One) | |
| 312 | + migrate_to_v"+version_str+" | |
| 313 | + ( | |
| 314 | + DataBase db, | |
| 315 | + (LogLevel, String) -> One logger, | |
| 316 | + )= | |
| 317 | + if to_v"+version_str+"_pre(db, logger) is failure then failure | |
| 318 | + else if create_v"+version_str+"_tables(db, logger) is failure then failure | |
| 319 | + else if to_v"+version_str+"_post(db, logger) is failure then failure | |
| 320 | + else create_v"+version_str+"_indexes(db, logger) | |
| 321 | +. | |
| 322 | + | |
| 323 | +global define Migration | |
| 324 | + "+app_name+"_dbm_to_v"+version_str+" | |
| 325 | + = | |
| 326 | + migration(db_model_version, migrate_to_v"+version_str+", create_v"+version_str+"_tables, create_v"+version_str+"_indexes) | |
| 327 | +. | |
| 328 | + | |
| 329 | +read hayamiki_lib/view/view_table_manager_types.anubis | |
| 330 | +read src/database/generated/vtm.anubis | |
| 331 | + | |
| 332 | +global define VTM | |
| 333 | + "+app_name+"_vtm_v"+version_str+" | |
| 334 | + = | |
| 335 | + vtm( | |
| 336 | + db_model_version, | |
| 337 | + vtm_view_list(generated_vtm_view_list), | |
| 338 | + vtm_edit_list(generated_vtm_edit_list), | |
| 339 | + generated_hk_table_controller_list | |
| 340 | + ) | |
| 341 | +. | |
| 342 | + ") | |
| 343 | + }}} | |
| 344 | +. | ... | ... |
src/generation/SQL_get_all.anubis
| ... | ... | @@ -8,150 +8,34 @@ |
| 8 | 8 | |
| 9 | 9 | read hayamiki_lib/types/hayamiki.anubis |
| 10 | 10 | read tools/streams.anubis |
| 11 | -read columns.anubis | |
| 11 | +read app/app_types.anubis | |
| 12 | +read SQLite/SQL_get_all.anubis | |
| 13 | +read PostgreSQL/SQL_get_all.anubis | |
| 12 | 14 | |
| 13 | 15 | public define Maybe(One) |
| 14 | - generate_get_all | |
| 16 | + generate_get_all_with_clause | |
| 15 | 17 | ( |
| 16 | - Stream stream, | |
| 17 | - HK_Table table | |
| 18 | + Stream stream, | |
| 19 | + HK_DB_engine hk_db_engine, //db engine to use for generation | |
| 20 | + HK_Table table | |
| 18 | 21 | )= |
| 19 | - since table is hk_table(name, short_name, model, _), | |
| 20 | - since model is hk_model(columns, constraints, _), | |
| 21 | - with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 22 | - | |
| 23 | - //generate the type of the table that contain all components | |
| 24 | - if write_string(stream, | |
| 25 | - "\n\n"+ | |
| 26 | - "public define List("+type_name+")\n"+ | |
| 27 | - " _get_all_"+name+"\n"+ | |
| 28 | - " (\n"+ | |
| 29 | - " One -> SQLite3Row table_cursor,\n"+ | |
| 30 | - " List("+type_name+") so_far\n"+ | |
| 31 | - " ) =\n"+ | |
| 32 | - " if extract_"+name+"(table_cursor) is\n"+ | |
| 33 | - " {\n"+ | |
| 34 | - " failure then reverse(so_far),\n"+ | |
| 35 | - " success(data) then _get_all_"+name+"(table_cursor, [data . so_far])\n"+ | |
| 36 | - " }.\n"+ | |
| 37 | - "\n\n" | |
| 38 | - //SQL query | |
| 39 | -// "public define List("+type_name+")\n"+ | |
| 40 | -// " get_all_"+name+"\n"+ | |
| 41 | -// " (\n"+ | |
| 42 | -// " SQLite3DataBase db,\n"+ | |
| 43 | -// " )=\n"+ | |
| 44 | -// " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ | |
| 45 | -// " {\n"+ | |
| 46 | -// " error(_) then [],\n"+ | |
| 47 | -// " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ | |
| 48 | -// " }.\n"+ | |
| 49 | -// "\n\n" | |
| 50 | - ) is //end of the function | |
| 22 | + if hk_db_engine is | |
| 51 | 23 | { |
| 52 | - failure then println("can't write generate_get_all "+type_name); failure, | |
| 53 | - success(_) then success(unique) | |
| 54 | - }. | |
| 55 | - | |
| 56 | -//public define JsonMember | |
| 57 | -// get_component | |
| 58 | -// ( | |
| 59 | -// String component_name, | |
| 60 | -// Crm_price_level type | |
| 61 | -// )= | |
| 62 | -// if component_name = "id" then json_member(component_name, json_int(type.id)) | |
| 63 | -// else if component_name = "code" then json_member(component_name, json_string(type.code)) | |
| 64 | -// else if component_name = "label" then json_member(component_name, json_string(type.label)) | |
| 65 | -// else if component_name = "active" then json_member(component_name, json_bool(type.active)) | |
| 66 | -// else if component_name = "module" then json_member(component_name, json_string(type.module)) | |
| 67 | -// else json_member(component_name, json_null) | |
| 68 | -//. | |
| 24 | + sqlite3 then generate_sqlite3_get_all_with_clause(stream, table) | |
| 25 | + postgresql then generate_postgresql_get_all_with_clause(stream, table) | |
| 26 | + } | |
| 27 | +. | |
| 69 | 28 | |
| 70 | 29 | public define Maybe(One) |
| 71 | - generate_get_all_with_clause | |
| 30 | + generate_get_all | |
| 72 | 31 | ( |
| 73 | - Stream stream, | |
| 74 | - HK_Table table | |
| 32 | + Stream stream, | |
| 33 | + HK_DB_engine hk_db_engine, //db engine to use for generation | |
| 34 | + HK_Table table | |
| 75 | 35 | )= |
| 76 | - since table is hk_table(name, short_name, model, _), | |
| 77 | - since model is hk_model(columns, constraints, _), | |
| 78 | - with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 79 | - | |
| 80 | - //generate the type of the table that contain all components | |
| 81 | - if write_string(stream, | |
| 82 | - //SQL query | |
| 83 | - "public define Maybe(One -> SQLite3Row)\n"+ | |
| 84 | - " get_all_"+name+"_by_clause\n"+ | |
| 85 | - " (\n"+ | |
| 86 | - " SQLite3DataBase db,\n"+ | |
| 87 | - " String clause\n"+ | |
| 88 | - " )=\n"+ | |
| 89 | - " with final_clause = if clause = \"\" then\n"+ | |
| 90 | - " \"\"\n"+ | |
| 91 | - " else\n"+ | |
| 92 | - " \"WHERE \"+clause,\n"+ | |
| 93 | - "\n"+ | |
| 94 | - " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+" \"+final_clause+\";\", [], \"get_all_"+name+"_by_clause\") is\n"+ | |
| 95 | - " {\n"+ | |
| 96 | - " error(_) then failure,\n"+ | |
| 97 | - " ok(_, cursor, _) then success(cursor)\n"+ | |
| 98 | - " }\n"+ | |
| 99 | - ".\n"+ | |
| 100 | - "\n"+ | |
| 101 | - "public define List("+type_name+")\n"+ | |
| 102 | - " get_all_"+name+"_by_clause_to_list_type\n"+ | |
| 103 | - " (\n"+ | |
| 104 | - " SQLite3DataBase db,\n"+ | |
| 105 | - " String clause\n"+ | |
| 106 | - " )=\n"+ | |
| 107 | - " if get_all_"+name+"_by_clause(db, clause) is\n"+ | |
| 108 | - " {\n"+ | |
| 109 | - " failure then [],\n"+ | |
| 110 | - " success(cursor) then _get_all_"+name+"(cursor, [])\n"+ | |
| 111 | - " }\n"+ | |
| 112 | - ".\n"+ | |
| 113 | - | |
| 114 | -//"public define List(JsonValue)\n"+ | |
| 115 | -//" _get_all_"+name+"_to_json\n"+ | |
| 116 | -//" (\n"+ | |
| 117 | -//" SQLite3DataBase db,\n"+ | |
| 118 | -//" List(((Int -> SQLite3Datum) -> JsonMember)) extractors,\n"+ | |
| 119 | -//" One -> SQLite3Row table_cursor,\n"+ | |
| 120 | -//" List(JsonValue) so_far\n"+ | |
| 121 | -//" ) =\n"+ | |
| 122 | -//" if extract_"+name+"_cursor_to_json(db, extractors, table_cursor) is\n"+ | |
| 123 | -//" {\n"+ | |
| 124 | -//" failure then reverse(so_far),\n"+ | |
| 125 | -//" success(data) then _get_all_"+name+"_to_json(db, extractors, table_cursor, [data . so_far])\n"+ | |
| 126 | -//" }\n"+ | |
| 127 | -//".\n"+ | |
| 128 | - | |
| 129 | -"public define JsonValue\n"+ | |
| 130 | -" get_all_"+name+"_by_clause_to_json\n"+ | |
| 131 | -" (\n"+ | |
| 132 | -" SQLite3DataBase db,\n"+ | |
| 133 | -" List(String) columns,\n"+ | |
| 134 | -" Bool resolve_fk,\n"+ | |
| 135 | -" HK_Referer referer,\n"+ | |
| 136 | -" String filter,\n"+ | |
| 137 | -" String order_by\n"+ | |
| 138 | -" )=\n"+ | |
| 139 | -" with ref_clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n"+ | |
| 140 | -" with final_columns = if length(columns) = 0 then [\"id\". "+name+"_columns] else columns,\n\n"+ | |
| 141 | -" with _and_ = if length(ref_clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+ | |
| 142 | -" if get_all_"+name+"_by_clause(db, ref_clause+_and_+filter+\" \"+order_by) is\n"+ | |
| 143 | -" {\n"+ | |
| 144 | -" failure then json_array([]),\n"+ | |
| 145 | -" success(cursor) then\n"+ | |
| 146 | -" json_array(\n"+ | |
| 147 | -//" _get_all_"+name+"_to_json(db, make_"+name+"_json_extractor(db, final_columns, resolve_fk), cursor, [])\n"+ | |
| 148 | -" get_all_to_json(db, make_"+name+"_json_extractor(db, final_columns, resolve_fk), cursor, [])\n"+ | |
| 149 | -" )\n"+ | |
| 150 | -" }\n"+ | |
| 151 | -".\n" | |
| 152 | - ) is //end of the function | |
| 36 | + if hk_db_engine is | |
| 153 | 37 | { |
| 154 | - failure then println("can't write generate_get_all "+type_name); failure, | |
| 155 | - success(_) then success(unique) | |
| 38 | + sqlite3 then generate_sqlite3_get_all(stream, table) | |
| 39 | + postgresql then generate_postgresql_get_all(stream, table) | |
| 156 | 40 | } |
| 157 | 41 | . | ... | ... |
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 17/05/2025 | |
| 5 | + * Time: 23:41 | |
| 6 | + * © David RENÉ | |
| 7 | + */ | |
| 8 | + | |
| 9 | + | |
| 10 | +read hayamiki_lib/types/hayamiki.anubis | |
| 11 | +read tools/streams.anubis | |
| 12 | +read ../columns.anubis | |
| 13 | + | |
| 14 | +public define Maybe(One) | |
| 15 | + generate_sqlite3_get_all | |
| 16 | + ( | |
| 17 | + Stream stream, | |
| 18 | + HK_Table table | |
| 19 | + )= | |
| 20 | + since table is hk_table(name, short_name, model, _), | |
| 21 | + since model is hk_model(columns, constraints, _), | |
| 22 | + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 23 | + | |
| 24 | + //generate the type of the table that contain all components | |
| 25 | + if write_string(stream, | |
| 26 | + "\n\n"+ | |
| 27 | + "public define List("+type_name+")\n"+ | |
| 28 | + " _get_all_"+name+"\n"+ | |
| 29 | + " (\n"+ | |
| 30 | + " One -> SQLite3Row table_cursor,\n"+ | |
| 31 | + " List("+type_name+") so_far\n"+ | |
| 32 | + " ) =\n"+ | |
| 33 | + " if extract_"+name+"(table_cursor) is\n"+ | |
| 34 | + " {\n"+ | |
| 35 | + " failure then reverse(so_far),\n"+ | |
| 36 | + " success(data) then _get_all_"+name+"(table_cursor, [data . so_far])\n"+ | |
| 37 | + " }.\n"+ | |
| 38 | + "\n\n" | |
| 39 | + //SQL query | |
| 40 | +// "public define List("+type_name+")\n"+ | |
| 41 | +// " get_all_"+name+"\n"+ | |
| 42 | +// " (\n"+ | |
| 43 | +// " SQLite3DataBase db,\n"+ | |
| 44 | +// " )=\n"+ | |
| 45 | +// " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ | |
| 46 | +// " {\n"+ | |
| 47 | +// " error(_) then [],\n"+ | |
| 48 | +// " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ | |
| 49 | +// " }.\n"+ | |
| 50 | +// "\n\n" | |
| 51 | + ) is //end of the function | |
| 52 | + { | |
| 53 | + failure then println("can't write generate_get_all "+type_name); failure, | |
| 54 | + success(_) then success(unique) | |
| 55 | + }. | |
| 56 | + | |
| 57 | +//public define JsonMember | |
| 58 | +// get_component | |
| 59 | +// ( | |
| 60 | +// String component_name, | |
| 61 | +// Crm_price_level type | |
| 62 | +// )= | |
| 63 | +// if component_name = "id" then json_member(component_name, json_int(type.id)) | |
| 64 | +// else if component_name = "code" then json_member(component_name, json_string(type.code)) | |
| 65 | +// else if component_name = "label" then json_member(component_name, json_string(type.label)) | |
| 66 | +// else if component_name = "active" then json_member(component_name, json_bool(type.active)) | |
| 67 | +// else if component_name = "module" then json_member(component_name, json_string(type.module)) | |
| 68 | +// else json_member(component_name, json_null) | |
| 69 | +//. | |
| 70 | + | |
| 71 | +public define Maybe(One) | |
| 72 | + generate_sqlite3_get_all_with_clause | |
| 73 | + ( | |
| 74 | + Stream stream, | |
| 75 | + HK_Table table | |
| 76 | + )= | |
| 77 | + since table is hk_table(name, short_name, model, _), | |
| 78 | + since model is hk_model(columns, constraints, _), | |
| 79 | + with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type. | |
| 80 | + | |
| 81 | + //generate the type of the table that contain all components | |
| 82 | + if write_string(stream, | |
| 83 | + //SQL query | |
| 84 | + "public define Maybe(One -> SQLite3Row)\n"+ | |
| 85 | + " get_all_"+name+"_by_clause\n"+ | |
| 86 | + " (\n"+ | |
| 87 | + " SQLite3DataBase db,\n"+ | |
| 88 | + " String clause\n"+ | |
| 89 | + " )=\n"+ | |
| 90 | + " with final_clause = if clause = \"\" then\n"+ | |
| 91 | + " \"\"\n"+ | |
| 92 | + " else\n"+ | |
| 93 | + " \"WHERE \"+clause,\n"+ | |
| 94 | + "\n"+ | |
| 95 | + " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+" \"+final_clause+\";\", [], \"get_all_"+name+"_by_clause\") is\n"+ | |
| 96 | + " {\n"+ | |
| 97 | + " error(_) then failure,\n"+ | |
| 98 | + " ok(_, cursor, _) then success(cursor)\n"+ | |
| 99 | + " }\n"+ | |
| 100 | + ".\n"+ | |
| 101 | + "\n"+ | |
| 102 | + "public define List("+type_name+")\n"+ | |
| 103 | + " get_all_"+name+"_by_clause_to_list_type\n"+ | |
| 104 | + " (\n"+ | |
| 105 | + " SQLite3DataBase db,\n"+ | |
| 106 | + " String clause\n"+ | |
| 107 | + " )=\n"+ | |
| 108 | + " if get_all_"+name+"_by_clause(db, clause) is\n"+ | |
| 109 | + " {\n"+ | |
| 110 | + " failure then [],\n"+ | |
| 111 | + " success(cursor) then _get_all_"+name+"(cursor, [])\n"+ | |
| 112 | + " }\n"+ | |
| 113 | + ".\n"+ | |
| 114 | + | |
| 115 | +//"public define List(JsonValue)\n"+ | |
| 116 | +//" _get_all_"+name+"_to_json\n"+ | |
| 117 | +//" (\n"+ | |
| 118 | +//" SQLite3DataBase db,\n"+ | |
| 119 | +//" List(((Int -> SQLite3Datum) -> JsonMember)) extractors,\n"+ | |
| 120 | +//" One -> SQLite3Row table_cursor,\n"+ | |
| 121 | +//" List(JsonValue) so_far\n"+ | |
| 122 | +//" ) =\n"+ | |
| 123 | +//" if extract_"+name+"_cursor_to_json(db, extractors, table_cursor) is\n"+ | |
| 124 | +//" {\n"+ | |
| 125 | +//" failure then reverse(so_far),\n"+ | |
| 126 | +//" success(data) then _get_all_"+name+"_to_json(db, extractors, table_cursor, [data . so_far])\n"+ | |
| 127 | +//" }\n"+ | |
| 128 | +//".\n"+ | |
| 129 | + | |
| 130 | +"public define JsonValue\n"+ | |
| 131 | +" get_all_"+name+"_by_clause_to_json\n"+ | |
| 132 | +" (\n"+ | |
| 133 | +" SQLite3DataBase db,\n"+ | |
| 134 | +" List(String) columns,\n"+ | |
| 135 | +" Bool resolve_fk,\n"+ | |
| 136 | +" HK_Referer referer,\n"+ | |
| 137 | +" String filter,\n"+ | |
| 138 | +" String order_by\n"+ | |
| 139 | +" )=\n"+ | |
| 140 | +" with ref_clause = referer_to_sql_clause(referer, \""+name+"\", "+name+"_columns),\n"+ | |
| 141 | +" with final_columns = if length(columns) = 0 then [\"id\". "+name+"_columns] else columns,\n\n"+ | |
| 142 | +" with _and_ = if length(ref_clause) > 0 & length(filter) > 0 then \" AND \" else \"\",\n"+ | |
| 143 | +" if get_all_"+name+"_by_clause(db, ref_clause+_and_+filter+\" \"+order_by) is\n"+ | |
| 144 | +" {\n"+ | |
| 145 | +" failure then json_array([]),\n"+ | |
| 146 | +" success(cursor) then\n"+ | |
| 147 | +" json_array(\n"+ | |
| 148 | +//" _get_all_"+name+"_to_json(db, make_"+name+"_json_extractor(db, final_columns, resolve_fk), cursor, [])\n"+ | |
| 149 | +" get_all_to_json(db, make_"+name+"_json_extractor(db, final_columns, resolve_fk), cursor, [])\n"+ | |
| 150 | +" )\n"+ | |
| 151 | +" }\n"+ | |
| 152 | +".\n" | |
| 153 | + ) is //end of the function | |
| 154 | + { | |
| 155 | + failure then println("can't write generate_get_all "+type_name); failure, | |
| 156 | + success(_) then success(unique) | |
| 157 | + } | |
| 158 | +. | ... | ... |
| 1 | +/* | |
| 2 | + * Created by PyramIDE. | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 24/01/2016 | |
| 5 | + * Time: 18:13 | |
| 6 | + * © David RENÉ | |
| 7 | + | |
| 8 | +Hayamiki is Copyright © 2016-2025 by David RENÉ | |
| 9 | +All rights reserved. | |
| 10 | + | |
| 11 | +Redistribution and use in source and binary forms, with or without modification, | |
| 12 | +are permitted provided that the following conditions are met: | |
| 13 | + | |
| 14 | +1. Redistributions of source code must retain the above copyright notice, | |
| 15 | + this list of conditions and the following disclaimer. | |
| 16 | + | |
| 17 | +2. Redistributions in binary form must reproduce the above copyright notice, | |
| 18 | + this list of conditions and the following disclaimer in the documentation | |
| 19 | + and/or other materials provided with the distribution. | |
| 20 | + | |
| 21 | +THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
| 22 | +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | |
| 23 | +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 24 | +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | |
| 25 | +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 26 | +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 27 | +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 28 | +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 29 | +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | +POSSIBILITY OF SUCH DAMAGE. | |
| 31 | + */ | |
| 32 | + | |
| 33 | + | |
| 34 | +read hayamiki_lib/types/hayamiki.anubis | |
| 35 | +read tools/basis.anubis | |
| 36 | +read tools/int.anubis | |
| 37 | +read system/string.anubis | |
| 38 | +read system/files.anubis | |
| 39 | +read data_base/sqlite.anubis | |
| 40 | +read tools/streams.anubis | |
| 41 | +read tools/ISO-8601.anubis | |
| 42 | + | |
| 43 | +read ../fields.anubis | |
| 44 | +read ../columns.anubis | |
| 45 | + | |
| 46 | +read ../../utils/utils.anubis | |
| 47 | + | |
| 48 | +define String | |
| 49 | + create_table_generate_one_column | |
| 50 | + ( | |
| 51 | + HK_Model_Column column, | |
| 52 | + Int fill_size | |
| 53 | + )= | |
| 54 | + since column is hk_column(name, col_type, attributes, _), | |
| 55 | + | |
| 56 | + fill(escaped_quoted_sqlite_reserved_keyword(name), fill_size)+ to_sqlite_SQL_CREATE(col_type, attributes, name) | |
| 57 | + . | |
| 58 | + | |
| 59 | +define String | |
| 60 | + create_table_generate_columns | |
| 61 | + ( | |
| 62 | + List(HK_Model_Column) columns, | |
| 63 | + String indent | |
| 64 | + )= | |
| 65 | + //get the longest column name size, to be able to make formatting according to column name. | |
| 66 | + with column_max_size = max(columns), | |
| 67 | + join(",\n"+indent, map((HK_Model_Column column) |-> create_table_generate_one_column(column, column_max_size+1), columns)) | |
| 68 | + . | |
| 69 | + | |
| 70 | +define String | |
| 71 | + to_String | |
| 72 | + ( | |
| 73 | + HK_On_Conflict on_conflict | |
| 74 | + )= | |
| 75 | + if on_conflict is | |
| 76 | + { | |
| 77 | + rollback then "ROLLBACK", | |
| 78 | + abort then "ABORT", | |
| 79 | + fail then "FAIL", | |
| 80 | + ignore then "IGNORE", | |
| 81 | + replace then "REPLACE" | |
| 82 | + } | |
| 83 | +. | |
| 84 | + | |
| 85 | +define String | |
| 86 | + create_table_generate_one_constraint | |
| 87 | + ( | |
| 88 | + HK_Constraint constraint, | |
| 89 | + String indent | |
| 90 | + )= | |
| 91 | + since constraint is unique(_name, columns, _on_conflict), | |
| 92 | + with name = if _name = "" then "" else "CONSTRAINT "+_name+" ", | |
| 93 | + ",\n"+ | |
| 94 | + indent+name+"UNIQUE (\n"+ | |
| 95 | + indent+indent+join(",\n"+indent+indent, escaped_quoted_sqlite_reserved_keyword(columns))+"\n"+ | |
| 96 | + indent+")\n"+ | |
| 97 | + indent+"ON CONFLICT "+to_String(_on_conflict) | |
| 98 | +. | |
| 99 | + | |
| 100 | +define String | |
| 101 | + create_table_generate_constraints | |
| 102 | + ( | |
| 103 | + List(HK_Constraint) constraints, | |
| 104 | + String indent | |
| 105 | + )= | |
| 106 | + join(",\n"+indent, map((HK_Constraint constraint) |-> create_table_generate_one_constraint(constraint, indent), constraints)) | |
| 107 | +. | |
| 108 | + | |
| 109 | +define String | |
| 110 | + create_table_generate_one_table | |
| 111 | + ( | |
| 112 | + HK_Table table | |
| 113 | + )= | |
| 114 | + since table is hk_table(name, short_name, model, display), | |
| 115 | + since model is hk_model( columns, constraints, _), | |
| 116 | + | |
| 117 | + "\n"+ | |
| 118 | + " // "+to_upper(name)+"\n"+ | |
| 119 | + "public define String create_table_"+name+" =\n"+ | |
| 120 | + "\"CREATE TABLE "+name+" (\n"+ | |
| 121 | + //columns | |
| 122 | + " "+create_table_generate_columns([hk_column("id", p_key) . columns], " ")+ | |
| 123 | + create_table_generate_constraints(constraints, " ")+ | |
| 124 | + "\n)\".\n" | |
| 125 | + . | |
| 126 | + | |
| 127 | +define String | |
| 128 | + create_table_generate_all_tables | |
| 129 | + ( | |
| 130 | + List(HK_App) apps, // | |
| 131 | + List(HK_Table) tables, //list of the table model description | |
| 132 | + String so_far | |
| 133 | + )= | |
| 134 | + if tables is | |
| 135 | + { | |
| 136 | + [] then //no more table to generate | |
| 137 | + if apps is | |
| 138 | + { | |
| 139 | + [] then //no more apps to generate | |
| 140 | + so_far, //return the all create table generated so far | |
| 141 | + [app. t_apps] then //another app available | |
| 142 | + since app is hk_app(name, _, _, app_tables), | |
| 143 | + create_table_generate_all_tables(t_apps, app_tables, so_far + "\n /************ TABLES for Application '"+name+"' ***************/") | |
| 144 | + }, | |
| 145 | + | |
| 146 | + [table . t] then | |
| 147 | + //generate the current table "CREATE TABLE" | |
| 148 | + create_table_generate_all_tables(apps, t, so_far + create_table_generate_one_table(table)) | |
| 149 | + }. | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | +define String | |
| 154 | + generate_all_tables_list | |
| 155 | + ( | |
| 156 | + List(HK_App) apps, | |
| 157 | +// List(HK_Table) tables, //list of the table model description | |
| 158 | + String indent | |
| 159 | + )= | |
| 160 | + //calculate then longest table name and add 4 for enclosed quote + coma + final space | |
| 161 | + //hence we can make a beautiful formatting | |
| 162 | + with max_space = longest_table_name_size(apps, 0) + 4, | |
| 163 | + join(",\n", | |
| 164 | + map_append((HK_App app) |-> since app is hk_app(_, _, _, tables), | |
| 165 | + map((HK_Table table) |-> indent+"table("+fill("\""+table.name+"\",", max_space)+"create_table_"+table.name+")", tables), apps)). | |
| 166 | + | |
| 167 | +public define Maybe(One) | |
| 168 | + generate_sqlite_create_table | |
| 169 | + ( | |
| 170 | + String app_name, | |
| 171 | + List(HK_App) apps, //list of the table model description | |
| 172 | + String dest_dir, | |
| 173 | + String version, | |
| 174 | + String _sha1 | |
| 175 | + )= | |
| 176 | + | |
| 177 | + with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language | |
| 178 | + | |
| 179 | + with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", | |
| 180 | + with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", | |
| 181 | + //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis", | |
| 182 | + //create all necessary directories if doesn't exist. | |
| 183 | + make_directories(file_name); | |
| 184 | + | |
| 185 | + //create script file name as new file. Previous file with same name will be erased | |
| 186 | + if file(create_file_name, new) is | |
| 187 | + { | |
| 188 | + failure then println("Can't create script "+create_file_name);failure, | |
| 189 | + success(fd_script) then | |
| 190 | + with script_stream = make_stream(fd_script), | |
| 191 | + //write into script file the generated create table | |
| 192 | + if write_string(script_stream, | |
| 193 | +"/* | |
| 194 | + * Created by 早見木 (Hayamiki). | |
| 195 | + * Date: "+_Int_to_ISO_8601_date(now)+" | |
| 196 | + * Time: "+_Int_to_ISO_8601_time(now)+" | |
| 197 | + */ | |
| 198 | + | |
| 199 | +read system/logger.anubis | |
| 200 | +read xlib/database/migration_common_sqlite3.anubis | |
| 201 | +read data_base/sqlite_foreign_key.anubis | |
| 202 | +read data_base/db_types.anubis\n"+ | |
| 203 | + //call the generation of all tables | |
| 204 | + create_table_generate_all_tables(apps, [], "")+ | |
| 205 | + //TODO make indexes | |
| 206 | + "\npublic define List(String) db_indexes = [].\n"+ | |
| 207 | + "// ///////////////////////////////\n"+ | |
| 208 | + "// Foreign keys \n"+ | |
| 209 | + "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n\n\n | |
| 210 | +define String _version = \""+version+"\". | |
| 211 | + | |
| 212 | +public define Maybe(One) | |
| 213 | + create_v"+version_str+"_tables | |
| 214 | + ( | |
| 215 | + SQLite3DataBase db, | |
| 216 | + (LogLevel, String) -> One logger | |
| 217 | + )= | |
| 218 | + logger(logInfo, \"DB migration create_v"+version_str+"_tables\"); | |
| 219 | + if drop_all_triggers(db, logger) is failure then | |
| 220 | + logger(logError, \"DB migration create_v"+version_str+"_tables: drop_all_triggers error\"); | |
| 221 | + failure | |
| 222 | + else | |
| 223 | + | |
| 224 | + with tables = (List(DbTable)) [ | |
| 225 | +"+generate_all_tables_list(apps, " ")+" | |
| 226 | + ], | |
| 227 | + if create_tables(db, logger, tables, _version) is | |
| 228 | + { | |
| 229 | + failure then | |
| 230 | + logger(logError, \"DB migration create_v"+version_str+"_tables: create_tables error\"); | |
| 231 | + failure, | |
| 232 | + success(_) then | |
| 233 | + if make_foreign_keys(db, logger, db_relations, _version) is failure then failure else | |
| 234 | + success(unique) | |
| 235 | + } | |
| 236 | +. | |
| 237 | + | |
| 238 | +public define DB_Version db_model_version = db_version(\""+version+"\", \""+_sha1+"\"). | |
| 239 | +\n\n" | |
| 240 | + | |
| 241 | + ) is | |
| 242 | + { | |
| 243 | + failure then println ("Can't generate script "+create_file_name);failure, | |
| 244 | + success(_) then | |
| 245 | + //create file with create table management (alter_table, etc...) | |
| 246 | + if file_exists(file_name) then | |
| 247 | + success(println("Skip creation of "+file_name+" because it's already exists and preventing to erase custom migration stuff")) | |
| 248 | + else | |
| 249 | + if file(file_name, new) is | |
| 250 | + { | |
| 251 | + failure then println("can't create file "+file_name);failure, | |
| 252 | + success(fd) then | |
| 253 | + with stream = make_stream(fd), | |
| 254 | + write_string(stream, | |
| 255 | +"/* | |
| 256 | + * Created by 早見木 (Hayamiki). | |
| 257 | + * Date: "+_Int_to_ISO_8601_date(now)+" | |
| 258 | + * Time: "+_Int_to_ISO_8601_time(now)+" | |
| 259 | + */ | |
| 260 | + * | |
| 261 | +read tools/basis.anubis | |
| 262 | +read system/files.anubis | |
| 263 | +read system/logger.anubis | |
| 264 | +read data_base/db_tools.anubis | |
| 265 | + | |
| 266 | +read xlib/database/db_utils.anubis | |
| 267 | +read xlib/database/migration_common_sqlite3.anubis | |
| 268 | +read xlib/database/migration_sqlite3.anubis | |
| 269 | +read data_base/alter_table.anubis | |
| 270 | + | |
| 271 | +read types/app_types.anubis | |
| 272 | +read app/app_constants.anubis | |
| 273 | +read app/app_loggers.anubis | |
| 274 | + | |
| 275 | +read database/generated/migration/to_"+version+"_create.anubis | |
| 276 | + | |
| 277 | +define String _version = \""+version+"\". | |
| 278 | + | |
| 279 | +public define Maybe(One) | |
| 280 | + create_v"+version_str+"_indexes | |
| 281 | + ( | |
| 282 | + SQLite3DataBase db, | |
| 283 | + (LogLevel, String) -> One logger | |
| 284 | + )= | |
| 285 | + logger(logInfo, \"DB migration create_v"+version_str+"_indexes\"); | |
| 286 | + if create_indexes(db, logger, db_indexes, _version) is failure then failure else | |
| 287 | + success(unique) | |
| 288 | + . | |
| 289 | + | |
| 290 | +define Maybe(One) | |
| 291 | + to_v"+version_str+"_pre | |
| 292 | + ( | |
| 293 | + SQLite3DataBase db, | |
| 294 | + (LogLevel, String) -> One logger | |
| 295 | + )= | |
| 296 | + logger(logInfo, \"DB migration to_v"+version_str+"_pre\"); | |
| 297 | + success(unique) | |
| 298 | +. | |
| 299 | + | |
| 300 | +define Maybe(One) | |
| 301 | + to_v"+version_str+"_post | |
| 302 | + ( | |
| 303 | + SQLite3DataBase db, | |
| 304 | + (LogLevel, String) -> One logger | |
| 305 | + )= | |
| 306 | + logger(logInfo, \"DB migration to_v"+version_str+"_post\"); | |
| 307 | + success(unique) | |
| 308 | +. | |
| 309 | + | |
| 310 | +public define Maybe(One) | |
| 311 | + migrate_to_v"+version_str+" | |
| 312 | + ( | |
| 313 | + SQLite3DataBase db, | |
| 314 | + (LogLevel, String) -> One logger, | |
| 315 | + )= | |
| 316 | + if to_v"+version_str+"_pre(db, logger) is failure then failure | |
| 317 | + else if create_v"+version_str+"_tables(db, logger) is failure then failure | |
| 318 | + else if to_v"+version_str+"_post(db, logger) is failure then failure | |
| 319 | + else create_v"+version_str+"_indexes(db, logger) | |
| 320 | +. | |
| 321 | + | |
| 322 | +global define Migration | |
| 323 | + "+app_name+"_dbm_to_v"+version_str+" | |
| 324 | + = | |
| 325 | + migration(db_model_version, migrate_to_v"+version_str+", create_v"+version_str+"_tables, create_v"+version_str+"_indexes) | |
| 326 | +. | |
| 327 | + | |
| 328 | +read hayamiki_lib/view/view_table_manager_types.anubis | |
| 329 | +read src/database/generated/vtm.anubis | |
| 330 | + | |
| 331 | +global define VTM | |
| 332 | + "+app_name+"_vtm_v"+version_str+" | |
| 333 | + = | |
| 334 | + vtm( | |
| 335 | + db_model_version, | |
| 336 | + vtm_view_list(generated_vtm_view_list), | |
| 337 | + vtm_edit_list(generated_vtm_edit_list), | |
| 338 | + generated_hk_table_controller_list | |
| 339 | + ) | |
| 340 | +. | |
| 341 | + ") | |
| 342 | + }}} | |
| 343 | +. | ... | ... |
src/generation/create_table.anubis
| 1 | 1 | /* |
| 2 | 2 | * Created by PyramIDE. |
| 3 | - * User: フランスのトトロ aka (David RENÉ) | |
| 4 | - * Date: 24/01/2016 | |
| 5 | - * Time: 18:13 | |
| 6 | - | |
| 7 | -Hayamiki is Copyright © 2016-2023 by David RENÉ | |
| 3 | + * User: フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 14/05/2025 | |
| 5 | + * Time: 16:56 | |
| 6 | + * © David RENÉ | |
| 7 | + | |
| 8 | +Hayamiki is Copyright © 2016-2025 by David RENÉ | |
| 8 | 9 | All rights reserved. |
| 9 | 10 | |
| 10 | 11 | Redistribution and use in source and binary forms, with or without modification, |
| ... | ... | @@ -27,466 +28,26 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | 30 | POSSIBILITY OF SUCH DAMAGE. |
| 30 | - */ | |
| 31 | - | |
| 31 | +*/ | |
| 32 | 32 | |
| 33 | +read app/app_types.anubis | |
| 33 | 34 | read hayamiki_lib/types/hayamiki.anubis |
| 34 | -read tools/basis.anubis | |
| 35 | -read tools/int.anubis | |
| 36 | -read system/string.anubis | |
| 37 | -read system/files.anubis | |
| 38 | -read data_base/sqlite.anubis | |
| 39 | -read tools/streams.anubis | |
| 40 | -read tools/ISO-8601.anubis | |
| 41 | - | |
| 42 | -read fields.anubis | |
| 43 | -read columns.anubis | |
| 44 | - | |
| 45 | -read utils/utils.anubis | |
| 46 | - | |
| 47 | -//define List(String) sqlite_reserved_keywords = (List(String)) | |
| 48 | -// [ | |
| 49 | -// "ABORT", | |
| 50 | -// "ACTION", | |
| 51 | -// "ADD", | |
| 52 | -// "AFTER", | |
| 53 | -// "ALL", | |
| 54 | -// "ALTER", | |
| 55 | -// "ALWAYS", | |
| 56 | -// "ANALYZE", | |
| 57 | -// "AND", | |
| 58 | -// "AS", | |
| 59 | -// "ASC", | |
| 60 | -// "ATTACH", | |
| 61 | -// "AUTOINCREMENT", | |
| 62 | -// "BEFORE", | |
| 63 | -// "BEGIN", | |
| 64 | -// "BETWEEN", | |
| 65 | -// "BY", | |
| 66 | -// "CASCADE", | |
| 67 | -// "CASE", | |
| 68 | -// "CAST", | |
| 69 | -// "CHECK", | |
| 70 | -// "COLLATE", | |
| 71 | -// "COLUMN", | |
| 72 | -// "COMMIT", | |
| 73 | -// "CONFLICT", | |
| 74 | -// "CONSTRAINT", | |
| 75 | -// "CREATE", | |
| 76 | -// "CROSS", | |
| 77 | -// "CURRENT", | |
| 78 | -// "CURRENT_DATE", | |
| 79 | -// "CURRENT_TIME", | |
| 80 | -// "CURRENT_TIMESTAMP", | |
| 81 | -// "DATABASE", | |
| 82 | -// "DEFAULT", | |
| 83 | -// "DEFERRABLE", | |
| 84 | -// "DEFERRED", | |
| 85 | -// "DELETE", | |
| 86 | -// "DESC", | |
| 87 | -// "DETACH", | |
| 88 | -// "DISTINCT", | |
| 89 | -// "DO", | |
| 90 | -// "DROP", | |
| 91 | -// "EACH", | |
| 92 | -// "ELSE", | |
| 93 | -// "END", | |
| 94 | -// "ESCAPE", | |
| 95 | -// "EXCEPT", | |
| 96 | -// "EXCLUDE", | |
| 97 | -// "EXCLUSIVE", | |
| 98 | -// "EXISTS", | |
| 99 | -// "EXPLAIN", | |
| 100 | -// "FAIL", | |
| 101 | -// "FILTER", | |
| 102 | -// "FOLLOWING", | |
| 103 | -// "FOR", | |
| 104 | -// "FOREIGN", | |
| 105 | -// "FROM", | |
| 106 | -// "FULL", | |
| 107 | -// "GENERATED", | |
| 108 | -// "GLOB", | |
| 109 | -// "GROUP", | |
| 110 | -// "GROUPS", | |
| 111 | -// "HAVING", | |
| 112 | -// "IF", | |
| 113 | -// "IGNORE", | |
| 114 | -// "IMMEDIATE", | |
| 115 | -// "IN", | |
| 116 | -// "INDEX", | |
| 117 | -// "INDEXED", | |
| 118 | -// "INITIALLY", | |
| 119 | -// "INNER", | |
| 120 | -// "INSERT", | |
| 121 | -// "INSTEAD", | |
| 122 | -// "INTERSECT", | |
| 123 | -// "INTO", | |
| 124 | -// "IS", | |
| 125 | -// "ISNULL", | |
| 126 | -// "JOIN", | |
| 127 | -// "KEY", | |
| 128 | -// "LAST", | |
| 129 | -// "LEFT", | |
| 130 | -// "LIKE", | |
| 131 | -// "LIMIT", | |
| 132 | -// "MATCH", | |
| 133 | -// "MATERIALIZED", | |
| 134 | -// "NATURAL", | |
| 135 | -// "NO", | |
| 136 | -// "NOT", | |
| 137 | -// "NOTHING", | |
| 138 | -// "NOTNULL", | |
| 139 | -// "NULL", | |
| 140 | -// "NULLS", | |
| 141 | -// "OF", | |
| 142 | -// "OFFSET", | |
| 143 | -// "ON", | |
| 144 | -// "OR", | |
| 145 | -// "ORDER", | |
| 146 | -// "OTHERS", | |
| 147 | -// "OUTER", | |
| 148 | -// "OVER", | |
| 149 | -// "PARTITION", | |
| 150 | -// "PLAN", | |
| 151 | -// "PRAGMA", | |
| 152 | -// "PRECEDING", | |
| 153 | -// "PRIMARY", | |
| 154 | -// "QUERY", | |
| 155 | -// "RAISE", | |
| 156 | -// "RANGE", | |
| 157 | -// "RECURSIVE", | |
| 158 | -// "REFERENCES", | |
| 159 | -// "REGEXP", | |
| 160 | -// "REINDEX", | |
| 161 | -// "RELEASE", | |
| 162 | -// "RENAME", | |
| 163 | -// "REPLACE", | |
| 164 | -// "RESTRICT", | |
| 165 | -// "RETURNING", | |
| 166 | -// "RIGHT", | |
| 167 | -// "ROLLBACK", | |
| 168 | -// "ROW", | |
| 169 | -// "ROWS", | |
| 170 | -// "SAVEPOINT", | |
| 171 | -// "SELECT", | |
| 172 | -// "SET", | |
| 173 | -// "TABLE", | |
| 174 | -// "TEMP", | |
| 175 | -// "TEMPORARY", | |
| 176 | -// "THEN", | |
| 177 | -// "TIES", | |
| 178 | -// "TO", | |
| 179 | -// "TRANSACTION", | |
| 180 | -// "TRIGGER", | |
| 181 | -// "UNBOUNDED", | |
| 182 | -// "UNION", | |
| 183 | -// "UNIQUE", | |
| 184 | -// "UPDATE", | |
| 185 | -// "USING", | |
| 186 | -// "VACUUM", | |
| 187 | -// "VALUES", | |
| 188 | -// "VIEW", | |
| 189 | -// "VIRTUAL", | |
| 190 | -// "WHEN", | |
| 191 | -// "WHERE", | |
| 192 | -// "WINDOW", | |
| 193 | -// "WITH", | |
| 194 | -// "WITHOUT" | |
| 195 | -//]. | |
| 196 | - | |
| 197 | -define String | |
| 198 | - create_table_generate_one_column | |
| 199 | - ( | |
| 200 | - HK_Model_Column column, | |
| 201 | - Int fill_size | |
| 202 | - )= | |
| 203 | - since column is hk_column(name, col_type, attributes, _), | |
| 204 | - | |
| 205 | - fill(escaped_quoted_sqlite_reserved_keyword(name), fill_size)+ to_SQL_CREATE(col_type, attributes, name) | |
| 206 | - . | |
| 207 | - | |
| 208 | -define String | |
| 209 | - create_table_generate_columns | |
| 210 | - ( | |
| 211 | - List(HK_Model_Column) columns, | |
| 212 | - String indent | |
| 213 | - )= | |
| 214 | - //get the longest column name size, to be able to make formatting according to column name. | |
| 215 | - with column_max_size = max(columns), | |
| 216 | - join(",\n"+indent, map((HK_Model_Column column) |-> create_table_generate_one_column(column, column_max_size+1), columns)) | |
| 217 | - . | |
| 218 | - | |
| 219 | -define String | |
| 220 | - to_String | |
| 221 | - ( | |
| 222 | - HK_On_Conflict on_conflict | |
| 223 | - )= | |
| 224 | - if on_conflict is | |
| 225 | - { | |
| 226 | - rollback then "ROLLBACK", | |
| 227 | - abort then "ABORT", | |
| 228 | - fail then "FAIL", | |
| 229 | - ignore then "IGNORE", | |
| 230 | - replace then "REPLACE" | |
| 231 | - } | |
| 232 | -. | |
| 233 | - | |
| 234 | -define String | |
| 235 | - create_table_generate_one_constraint | |
| 236 | - ( | |
| 237 | - HK_Constraint constraint, | |
| 238 | - String indent | |
| 239 | - )= | |
| 240 | - since constraint is unique(_name, columns, _on_conflict), | |
| 241 | - with name = if _name = "" then "" else "CONSTRAINT "+_name+" ", | |
| 242 | - ",\n"+ | |
| 243 | - indent+name+"UNIQUE (\n"+ | |
| 244 | - indent+indent+join(",\n"+indent+indent, escaped_quoted_sqlite_reserved_keyword(columns))+"\n"+ | |
| 245 | - indent+")\n"+ | |
| 246 | - indent+"ON CONFLICT "+to_String(_on_conflict) | |
| 247 | -. | |
| 248 | - | |
| 249 | -define String | |
| 250 | - create_table_generate_constraints | |
| 251 | - ( | |
| 252 | - List(HK_Constraint) constraints, | |
| 253 | - String indent | |
| 254 | - )= | |
| 255 | - join(",\n"+indent, map((HK_Constraint constraint) |-> create_table_generate_one_constraint(constraint, indent), constraints)) | |
| 256 | -. | |
| 257 | - | |
| 258 | -define String | |
| 259 | - create_table_generate_one_table | |
| 260 | - ( | |
| 261 | - HK_Table table | |
| 262 | - )= | |
| 263 | - since table is hk_table(name, short_name, model, display), | |
| 264 | - since model is hk_model( columns, constraints, _), | |
| 265 | - | |
| 266 | - "\n"+ | |
| 267 | - " // "+to_upper(name)+"\n"+ | |
| 268 | - "public define String create_table_"+name+" =\n"+ | |
| 269 | - "\"CREATE TABLE "+name+" (\n"+ | |
| 270 | - //columns | |
| 271 | - " "+create_table_generate_columns([hk_column("id", p_key) . columns], " ")+ | |
| 272 | - create_table_generate_constraints(constraints, " ")+ | |
| 273 | - "\n)\".\n" | |
| 274 | - . | |
| 275 | - | |
| 276 | -define String | |
| 277 | - create_table_generate_all_tables | |
| 278 | - ( | |
| 279 | - List(HK_App) apps, // | |
| 280 | - List(HK_Table) tables, //list of the table model description | |
| 281 | - String so_far | |
| 282 | - )= | |
| 283 | - if tables is | |
| 284 | - { | |
| 285 | - [] then //no more table to generate | |
| 286 | - if apps is | |
| 287 | - { | |
| 288 | - [] then //no more apps to generate | |
| 289 | - so_far, //return the all create table generated so far | |
| 290 | - [app. t_apps] then //another app available | |
| 291 | - since app is hk_app(name, _, _, app_tables), | |
| 292 | - create_table_generate_all_tables(t_apps, app_tables, so_far + "\n /************ TABLES for Application '"+name+"' ***************/") | |
| 293 | - }, | |
| 35 | +read SQLite/create_table.anubis | |
| 36 | +read PostgreSQL/create_table.anubis | |
| 294 | 37 | |
| 295 | - [table . t] then | |
| 296 | - //generate the current table "CREATE TABLE" | |
| 297 | - create_table_generate_all_tables(apps, t, so_far + create_table_generate_one_table(table)) | |
| 298 | - }. | |
| 299 | - | |
| 300 | - | |
| 301 | - | |
| 302 | -define String | |
| 303 | - generate_all_tables_list | |
| 304 | - ( | |
| 305 | - List(HK_App) apps, | |
| 306 | -// List(HK_Table) tables, //list of the table model description | |
| 307 | - String indent | |
| 308 | - )= | |
| 309 | - //calculate then longest table name and add 4 for enclosed quote + coma + final space | |
| 310 | - //hence we can make a beautiful formatting | |
| 311 | - with max_space = longest_table_name_size(apps, 0) + 4, | |
| 312 | - join(",\n", | |
| 313 | - map_append((HK_App app) |-> since app is hk_app(_, _, _, tables), | |
| 314 | - map((HK_Table table) |-> indent+"table("+fill("\""+table.name+"\",", max_space)+"create_table_"+table.name+")", tables), apps)). | |
| 315 | - | |
| 316 | 38 | public define Maybe(One) |
| 317 | 39 | generate_create_table |
| 318 | 40 | ( |
| 319 | 41 | String app_name, |
| 320 | - List(HK_App) apps, //list of the table model description | |
| 321 | - String dest_dir, | |
| 42 | + List(HK_App) apps, //list of the table model description | |
| 43 | + String dest_dir, //destination directory | |
| 44 | + HK_DB_engine hk_db_engine, //for which database engine we generate | |
| 322 | 45 | String version, |
| 323 | 46 | String _sha1 |
| 324 | 47 | )= |
| 325 | - | |
| 326 | - with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language | |
| 327 | - | |
| 328 | - with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", | |
| 329 | - with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", | |
| 330 | - //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis", | |
| 331 | - //create all necessary directories if doesn't exist. | |
| 332 | - make_directories(file_name); | |
| 333 | - | |
| 334 | - //create script file name as new file. Previous file with same name will be erased | |
| 335 | - if file(create_file_name, new) is | |
| 48 | + if hk_db_engine is | |
| 336 | 49 | { |
| 337 | - failure then println("Can't create script "+create_file_name);failure, | |
| 338 | - success(fd_script) then | |
| 339 | - with script_stream = make_stream(fd_script), | |
| 340 | - //write into script file the generated create table | |
| 341 | - if write_string(script_stream, | |
| 342 | -"/* | |
| 343 | - * Created by 早見木 (Hayamiki). | |
| 344 | - * Date: "+_Int_to_ISO_8601_date(now)+" | |
| 345 | - * Time: "+_Int_to_ISO_8601_time(now)+" | |
| 346 | - */ | |
| 347 | - | |
| 348 | -read system/logger.anubis | |
| 349 | -read xlib/database/migration_common_sqlite3.anubis | |
| 350 | -read data_base/sqlite_foreign_key.anubis | |
| 351 | -read data_base/db_types.anubis\n"+ | |
| 352 | - //call the generation of all tables | |
| 353 | - create_table_generate_all_tables(apps, [], "")+ | |
| 354 | - //TODO make indexes | |
| 355 | - "\npublic define List(String) db_indexes = [].\n"+ | |
| 356 | - "// ///////////////////////////////\n"+ | |
| 357 | - "// Foreign keys \n"+ | |
| 358 | - "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n\n\n | |
| 359 | -define String _version = \""+version+"\". | |
| 360 | - | |
| 361 | -public define Maybe(One) | |
| 362 | - create_v"+version_str+"_tables | |
| 363 | - ( | |
| 364 | - SQLite3DataBase db, | |
| 365 | - (LogLevel, String) -> One logger | |
| 366 | - )= | |
| 367 | - logger(logInfo, \"DB migration create_v"+version_str+"_tables\"); | |
| 368 | - if drop_all_triggers(db, logger) is failure then | |
| 369 | - logger(logError, \"DB migration create_v"+version_str+"_tables: drop_all_triggers error\"); | |
| 370 | - failure | |
| 371 | - else | |
| 372 | - | |
| 373 | - with tables = (List(DbTable)) [ | |
| 374 | -"+generate_all_tables_list(apps, " ")+" | |
| 375 | - ], | |
| 376 | - if create_tables(db, logger, tables, _version) is | |
| 377 | - { | |
| 378 | - failure then | |
| 379 | - logger(logError, \"DB migration create_v"+version_str+"_tables: create_tables error\"); | |
| 380 | - failure, | |
| 381 | - success(_) then | |
| 382 | - if make_foreign_keys(db, logger, db_relations, _version) is failure then failure else | |
| 383 | - success(unique) | |
| 50 | + sqlite3 then generate_sqlite_create_table(app_name, apps, dest_dir, version, _sha1), | |
| 51 | + postgresql then generate_postgresql_create_table(app_name, apps, dest_dir, version, _sha1), | |
| 384 | 52 | } |
| 385 | 53 | . |
| 386 | - | |
| 387 | -public define DB_Version db_model_version = db_version(\""+version+"\", \""+_sha1+"\"). | |
| 388 | -\n\n" | |
| 389 | - | |
| 390 | - ) is | |
| 391 | - { | |
| 392 | - failure then println ("Can't generate script "+create_file_name);failure, | |
| 393 | - success(_) then | |
| 394 | - //create file with create table management (alter_table, etc...) | |
| 395 | - if file_exists(file_name) then | |
| 396 | - success(println("Skip creation of "+file_name+" because it's already exists and preventing to erase custom migration stuff")) | |
| 397 | - else | |
| 398 | - if file(file_name, new) is | |
| 399 | - { | |
| 400 | - failure then println("can't create file "+file_name);failure, | |
| 401 | - success(fd) then | |
| 402 | - with stream = make_stream(fd), | |
| 403 | - write_string(stream, | |
| 404 | -"/* | |
| 405 | - * Created by 早見木 (Hayamiki). | |
| 406 | - * Date: "+_Int_to_ISO_8601_date(now)+" | |
| 407 | - * Time: "+_Int_to_ISO_8601_time(now)+" | |
| 408 | - */ | |
| 409 | - * | |
| 410 | -read tools/basis.anubis | |
| 411 | -read system/files.anubis | |
| 412 | -read system/logger.anubis | |
| 413 | -read data_base/db_tools.anubis | |
| 414 | - | |
| 415 | -read xlib/database/db_utils.anubis | |
| 416 | -read xlib/database/migration_common_sqlite3.anubis | |
| 417 | -read xlib/database/migration_sqlite3.anubis | |
| 418 | -read data_base/alter_table.anubis | |
| 419 | - | |
| 420 | -read types/app_types.anubis | |
| 421 | -read app/app_constants.anubis | |
| 422 | -read app/app_loggers.anubis | |
| 423 | - | |
| 424 | -read database/generated/migration/to_"+version+"_create.anubis | |
| 425 | - | |
| 426 | -define String _version = \""+version+"\". | |
| 427 | - | |
| 428 | -public define Maybe(One) | |
| 429 | - create_v"+version_str+"_indexes | |
| 430 | - ( | |
| 431 | - SQLite3DataBase db, | |
| 432 | - (LogLevel, String) -> One logger | |
| 433 | - )= | |
| 434 | - logger(logInfo, \"DB migration create_v"+version_str+"_indexes\"); | |
| 435 | - if create_indexes(db, logger, db_indexes, _version) is failure then failure else | |
| 436 | - success(unique) | |
| 437 | - . | |
| 438 | - | |
| 439 | -define Maybe(One) | |
| 440 | - to_v"+version_str+"_pre | |
| 441 | - ( | |
| 442 | - SQLite3DataBase db, | |
| 443 | - (LogLevel, String) -> One logger | |
| 444 | - )= | |
| 445 | - logger(logInfo, \"DB migration to_v"+version_str+"_pre\"); | |
| 446 | - success(unique) | |
| 447 | -. | |
| 448 | - | |
| 449 | -define Maybe(One) | |
| 450 | - to_v"+version_str+"_post | |
| 451 | - ( | |
| 452 | - SQLite3DataBase db, | |
| 453 | - (LogLevel, String) -> One logger | |
| 454 | - )= | |
| 455 | - logger(logInfo, \"DB migration to_v"+version_str+"_post\"); | |
| 456 | - success(unique) | |
| 457 | -. | |
| 458 | - | |
| 459 | -public define Maybe(One) | |
| 460 | - migrate_to_v"+version_str+" | |
| 461 | - ( | |
| 462 | - SQLite3DataBase db, | |
| 463 | - (LogLevel, String) -> One logger, | |
| 464 | - )= | |
| 465 | - if to_v"+version_str+"_pre(db, logger) is failure then failure | |
| 466 | - else if create_v"+version_str+"_tables(db, logger) is failure then failure | |
| 467 | - else if to_v"+version_str+"_post(db, logger) is failure then failure | |
| 468 | - else create_v"+version_str+"_indexes(db, logger) | |
| 469 | -. | |
| 470 | - | |
| 471 | -global define Migration | |
| 472 | - "+app_name+"_dbm_to_v"+version_str+" | |
| 473 | - = | |
| 474 | - migration(db_model_version, migrate_to_v"+version_str+", create_v"+version_str+"_tables, create_v"+version_str+"_indexes) | |
| 475 | -. | |
| 476 | - | |
| 477 | -read hayamiki_lib/view/view_table_manager_types.anubis | |
| 478 | -read src/database/generated/vtm.anubis | |
| 479 | - | |
| 480 | -global define VTM | |
| 481 | - "+app_name+"_vtm_v"+version_str+" | |
| 482 | - = | |
| 483 | - vtm( | |
| 484 | - db_model_version, | |
| 485 | - vtm_view_list(generated_vtm_view_list), | |
| 486 | - vtm_edit_list(generated_vtm_edit_list), | |
| 487 | - generated_hk_table_controller_list | |
| 488 | - ) | |
| 489 | -. | |
| 490 | - ") | |
| 491 | - }}} | |
| 492 | -. | ... | ... |
src/generation/fields.anubis
| ... | ... | @@ -69,7 +69,7 @@ public define String |
| 69 | 69 | }. |
| 70 | 70 | |
| 71 | 71 | public define String |
| 72 | - to_SQL_CREATE | |
| 72 | + to_sqlite_SQL_CREATE | |
| 73 | 73 | ( |
| 74 | 74 | HK_Model_Field t, |
| 75 | 75 | List(HK_Model_Attr) attributes, |
| ... | ... | @@ -103,25 +103,127 @@ public define String |
| 103 | 103 | }. |
| 104 | 104 | |
| 105 | 105 | public define String |
| 106 | + to_postgresql_SQL_CREATE | |
| 107 | + ( | |
| 108 | + HK_Model_Field t, | |
| 109 | + List(HK_Model_Attr) attributes, | |
| 110 | + String name //name of component into the type | |
| 111 | + ) = | |
| 112 | + if t is | |
| 113 | + { | |
| 114 | + //anubis(_T) then "ByteArray", | |
| 115 | + p_key then fill("BIGINT", 15) + (if name = "id" then " GENERATED BY DEFAULT AS IDENTITY" else ""), | |
| 116 | + boolean_field then fill("BOOLEAN", 15) + format_attributes(attributes), | |
| 117 | + date_field(dt_attrs) then | |
| 118 | + with new_attributes = if dt_attrs is auto_now_add then [default("CURRENT_DATE")] else attributes, | |
| 119 | + fill("DATE", 15) + format_attributes(attributes), | |
| 120 | + time_field(dt_attrs) then | |
| 121 | + with new_attributes = if dt_attrs is auto_now_add then [default("LOCALTIME(0)")] else attributes, | |
| 122 | + fill("TIME", 15) + format_attributes(new_attributes), | |
| 123 | + datetime_field(dt_attrs) then | |
| 124 | + with new_attributes = if dt_attrs is auto_now_add then [default("LOCALTIMESTAMP(0)")] else attributes, | |
| 125 | + fill("TIMESTAMP", 15) + format_attributes(new_attributes), | |
| 126 | + foreign_key(app,fk,_,_,fk_clause) then fill("BIGINT", 15) + format_attributes(attributes)+" REFERENCES "+fk+"(id) "+format_fk_clause(fk_clause), | |
| 127 | + integer_field(_) then fill("INTEGER", 15) + format_attributes(attributes), | |
| 128 | + float_field then fill("REAL", 15) + format_attributes(attributes), | |
| 129 | + char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), | |
| 130 | + password_field(size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), | |
| 131 | + text_field(_) then fill("TEXT", 15) + format_attributes(attributes), | |
| 132 | + color_field then fill("VARCHAR(8)",15)+ format_attributes(attributes), | |
| 133 | + phone_field(_) then fill("VARCHAR(20)", 15) + format_attributes(attributes), | |
| 134 | +// mobile_field then fill("VARCHAR(20)", 15) + format_attributes(attributes), | |
| 135 | + url_field then fill("VARCHAR(2048)", 15) + format_attributes(attributes), | |
| 136 | + email_field then fill("VARCHAR(254)", 15) + format_attributes(attributes), | |
| 137 | +}. | |
| 138 | + | |
| 139 | +define String | |
| 140 | + to_default_string | |
| 141 | + ( | |
| 142 | + Maybe(String) value, | |
| 143 | + String internal_default | |
| 144 | + )= | |
| 145 | + if value is | |
| 146 | + { | |
| 147 | + failure then internal_default | |
| 148 | + success(str) then | |
| 149 | + //try to remove the quote which enclosure sql string if any | |
| 150 | + with new_str = if first_char(str) is | |
| 151 | + { | |
| 152 | + failure then str, | |
| 153 | + success(f) then | |
| 154 | + if last_char(str) is | |
| 155 | + { failure then str | |
| 156 | + success(l) then | |
| 157 | + if f = "'" & l = "'" then | |
| 158 | + if sub_string(str, 1, length(str) - 2) is | |
| 159 | + { | |
| 160 | + failure then str, | |
| 161 | + success(unquoted_string) then | |
| 162 | + unquoted_string | |
| 163 | + } | |
| 164 | + else | |
| 165 | + str | |
| 166 | + } | |
| 167 | + }, | |
| 168 | + "\""+new_str+"\"" | |
| 169 | + } | |
| 170 | +. | |
| 171 | + | |
| 172 | +define String | |
| 173 | + to_default_boolean | |
| 174 | + ( | |
| 175 | + Maybe(String) value, | |
| 176 | + String internal_default | |
| 177 | + )= | |
| 178 | + if value is | |
| 179 | + { | |
| 180 | + failure then internal_default | |
| 181 | + success(str) then | |
| 182 | + //transform the string to real bool value | |
| 183 | + //and finally convert that bool value to String ("true" or "false") | |
| 184 | + to_String(to_Bool(str)) | |
| 185 | + } | |
| 186 | +. | |
| 187 | + | |
| 188 | +define Maybe(String) | |
| 189 | + get_default_value | |
| 190 | + ( | |
| 191 | + List(HK_Model_Attr) attributes | |
| 192 | + )= | |
| 193 | + if attributes is | |
| 194 | + { | |
| 195 | + [] then failure, //list finished, attribute default not found | |
| 196 | + [h . t] then | |
| 197 | + if h is default(def_string) then | |
| 198 | + success(def_string) | |
| 199 | + else | |
| 200 | + get_default_value(t) | |
| 201 | + } | |
| 202 | +. | |
| 203 | + | |
| 204 | +public define String | |
| 106 | 205 | to_Anubis_default |
| 107 | 206 | ( |
| 108 | - HK_Model_Field t | |
| 207 | + HK_Model_Field t, | |
| 208 | + List(HK_Model_Attr) attributes | |
| 109 | 209 | ) = |
| 210 | + with default = get_default_value(attributes), | |
| 211 | + | |
| 110 | 212 | if t is |
| 111 | 213 | { |
| 112 | 214 | //anubis(_T) then "constant_byte_array(0,0)", |
| 113 | 215 | p_key then "none", |
| 114 | 216 | //binary then "constant_byte_array(0,0)", |
| 115 | - boolean_field then "false", | |
| 217 | + boolean_field then to_default_boolean(default, "false"), | |
| 116 | 218 | date_field(_) then "db_date(\"\")", |
| 117 | 219 | time_field(_) then "db_time(\"\")", |
| 118 | 220 | datetime_field(_) then "db_datetime(\"\")", |
| 119 | 221 | foreign_key(_,_,_,_,_) then "(DB_id)none", |
| 120 | 222 | integer_field(_) then "(Int)0", |
| 121 | 223 | float_field then "(Float)0.0", |
| 122 | - char_field(choices,size) then "\"\"", | |
| 224 | + char_field(choices,size) then to_default_string(default, "\"\""), | |
| 123 | 225 | password_field(min_size) then "\"\"", |
| 124 | - text_field(_) then "\"\"", | |
| 226 | + text_field(_) then to_default_string(default, "\"\""), | |
| 125 | 227 | color_field then "\"#DDD\"", |
| 126 | 228 | phone_field(_) then "\"\"", |
| 127 | 229 | // mobile_field then "\"\"", | ... | ... |
src/generation/files.anubis
| ... | ... | @@ -18,6 +18,7 @@ read tools/streams.anubis |
| 18 | 18 | read tools/ISO-8601.anubis |
| 19 | 19 | |
| 20 | 20 | read app/app_version.anubis |
| 21 | +read app/app_types.anubis | |
| 21 | 22 | |
| 22 | 23 | read generation/header.anubis |
| 23 | 24 | read generation/types.anubis |
| ... | ... | @@ -36,12 +37,14 @@ read generation/SQL_get_count.anubis |
| 36 | 37 | read generation/SQL_get_all.anubis |
| 37 | 38 | read check.anubis |
| 38 | 39 | |
| 40 | + | |
| 39 | 41 | define Maybe(One) |
| 40 | 42 | generate_table |
| 41 | 43 | ( |
| 42 | - HK_Table org_table, //table to generate | |
| 43 | - String dest_dir, //root directory of the generation | |
| 44 | - Bool use_densaku //if true, this means the types are constructed by densaku for generating also the messages | |
| 44 | + HK_Table org_table, //table to generate | |
| 45 | + String dest_dir, //root directory of the generation | |
| 46 | + HK_DB_engine hk_db_engine, //db engine to use for generation | |
| 47 | + Bool use_densaku //if true, this means the types are constructed by densaku for generating also the messages | |
| 45 | 48 | ) |
| 46 | 49 | = |
| 47 | 50 | since org_table is hk_table(name, short_name, old_model, display), |
| ... | ... | @@ -50,7 +53,7 @@ define Maybe(One) |
| 50 | 53 | |
| 51 | 54 | with model = hk_model([hk_column("id", p_key, []). columns], constraints, show_string ), |
| 52 | 55 | with table = hk_table(name, short_name, model, display), |
| 53 | - println("Generating file for table ["+name+"]"); | |
| 56 | + println("Generating file for table ["+name+"] for db engine ["+to_String(hk_db_engine)+"]"); | |
| 54 | 57 | with file_name = dest_dir+"database/generated/"+name+".anubis", |
| 55 | 58 | |
| 56 | 59 | //create all necessary directories if doesn't exist. |
| ... | ... | @@ -70,8 +73,8 @@ define Maybe(One) |
| 70 | 73 | if generate_extract_web_arg_to_update_field(strm, table) is { failure then failure, success(_) then |
| 71 | 74 | if generate_extract_db_cursor_to_mb_type(strm, table) is { failure then failure, success(_) then |
| 72 | 75 | if generate_extract_db_cursor_to_json(strm, table) is { failure then failure, success(_) then |
| 73 | - if generate_get_all(strm, table) is { failure then failure, success(_) then | |
| 74 | - if generate_get_all_with_clause(strm, table) is { failure then failure, success(_) then | |
| 76 | + if generate_get_all(strm, hk_db_engine, table) is { failure then failure, success(_) then | |
| 77 | + if generate_get_all_with_clause(strm, hk_db_engine, table) is { failure then failure, success(_) then | |
| 75 | 78 | if generate_get_one_with_clause(strm, table) is { failure then failure, success(_) then |
| 76 | 79 | if generate_get_one(strm, table) is { failure then failure, success(_) then |
| 77 | 80 | if generate_get_one_json(strm, table) is { failure then failure, success(_) then |
| ... | ... | @@ -91,6 +94,7 @@ define One |
| 91 | 94 | ( |
| 92 | 95 | List(HK_Table) tables, //list of the table model description |
| 93 | 96 | String dest_dir, |
| 97 | + HK_DB_engine hk_db_engine, | |
| 94 | 98 | Bool use_densaku |
| 95 | 99 | ) |
| 96 | 100 | = |
| ... | ... | @@ -98,10 +102,10 @@ define One |
| 98 | 102 | { |
| 99 | 103 | [] then println("Generation finished"), |
| 100 | 104 | [h . t] then |
| 101 | - if generate_table(h, dest_dir, use_densaku) is | |
| 105 | + if generate_table(h, dest_dir, hk_db_engine, use_densaku) is | |
| 102 | 106 | { |
| 103 | 107 | failure then println("Generation error") |
| 104 | - success(_) then make_all_tables(t, dest_dir, use_densaku) | |
| 108 | + success(_) then make_all_tables(t, dest_dir, hk_db_engine, use_densaku) | |
| 105 | 109 | } |
| 106 | 110 | }. |
| 107 | 111 | |
| ... | ... | @@ -110,6 +114,7 @@ define One |
| 110 | 114 | ( |
| 111 | 115 | List(HK_App) apps, |
| 112 | 116 | String dest_dir, |
| 117 | + HK_DB_engine hk_db_engine, | |
| 113 | 118 | Bool use_densaku |
| 114 | 119 | |
| 115 | 120 | )= |
| ... | ... | @@ -117,7 +122,7 @@ define One |
| 117 | 122 | |
| 118 | 123 | map_forget((HK_App app) |-> since app is hk_app(app_name, _, _, tables), |
| 119 | 124 | println("generating tables for App ["+app_name+"]"); |
| 120 | - make_all_tables(tables, dest_dir, use_densaku), apps); | |
| 125 | + make_all_tables(tables, dest_dir, hk_db_engine, use_densaku), apps); | |
| 121 | 126 | |
| 122 | 127 | close_densaku_file(dest_dir, use_densaku) |
| 123 | 128 | . |
| ... | ... | @@ -190,6 +195,7 @@ define One |
| 190 | 195 | // List(String) so_far_writer, |
| 191 | 196 | // List(String) so_far_delete, |
| 192 | 197 | List(String) so_far_controllers, |
| 198 | + HK_DB_engine hk_db_engine, | |
| 193 | 199 | String dest_dir |
| 194 | 200 | )= |
| 195 | 201 | if tables is |
| ... | ... | @@ -199,7 +205,7 @@ define One |
| 199 | 205 | { |
| 200 | 206 | [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_controllers, dest_dir));println("Generation finished"), |
| 201 | 207 | [app . apps_t] then |
| 202 | - _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_controllers, dest_dir) | |
| 208 | + _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_controllers, hk_db_engine, dest_dir) | |
| 203 | 209 | |
| 204 | 210 | }, |
| 205 | 211 | |
| ... | ... | @@ -233,24 +239,25 @@ define One |
| 233 | 239 | hk_trigger_set(var([]), var([]), var([]), var([]), var([]), var([])) //initialize the triggers list as empty |
| 234 | 240 | )", |
| 235 | 241 | |
| 236 | - _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [controller . so_far_controllers], dest_dir) | |
| 242 | + _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [controller . so_far_controllers], hk_db_engine, dest_dir) | |
| 237 | 243 | }. |
| 238 | 244 | |
| 239 | 245 | define One |
| 240 | 246 | make_vtm |
| 241 | 247 | ( |
| 242 | - List(HK_App) apps, //list of the applications | |
| 248 | + List(HK_App) apps, //list of the applications | |
| 249 | + HK_DB_engine hk_db_engine, | |
| 243 | 250 | String dest_dir |
| 244 | 251 | ) |
| 245 | 252 | = |
| 246 | - _make_vtm(apps, [], [], [], [], [], dest_dir). | |
| 253 | + _make_vtm(apps, [], [], [], [], [], hk_db_engine, dest_dir). | |
| 247 | 254 | |
| 248 | 255 | |
| 249 | 256 | define Maybe(One) |
| 250 | 257 | generate_model_files |
| 251 | 258 | ( |
| 252 | 259 | HK_Database db, //database model description |
| 253 | - String destination_dir, | |
| 260 | + String _destination_dir, | |
| 254 | 261 | Bool use_densaku |
| 255 | 262 | )= |
| 256 | 263 | //before processing the generation we check if we need to do it, by checking the SHA1 generated with the |
| ... | ... | @@ -259,35 +266,39 @@ define Maybe(One) |
| 259 | 266 | |
| 260 | 267 | //process. We serialize the database model and make SHA1 of the result. This result is stored in file hayamiki.ini |
| 261 | 268 | //in root of destination_dir |
| 269 | + with destination_dir = _destination_dir+"/", | |
| 262 | 270 | with cur_dir = get_current_directory, |
| 263 | - println("\nHayamiki Generator 1.19"); | |
| 271 | + println("\nHayamiki Generator ["+product_version+"]"); | |
| 264 | 272 | println("current dir :"+cur_dir); |
| 265 | 273 | println("Destination dir: "+destination_dir); |
| 266 | 274 | with ini = loadIniFile(destination_dir+"/hayamiki.ini"), |
| 267 | 275 | |
| 268 | - with db_SHA1 = readString(ini, "DB_MODEL", "SHA1", "N/A"), | |
| 269 | - with version = readString(ini, "DB_MODEL", "Version", "0.0.0.0"), | |
| 270 | - with app_name= readString(ini, "DB_MODEL", "app_name", ""), | |
| 271 | - with engine = readString(ini, "DB_MODEL", "engine", "sqlite3"), | |
| 272 | - with hkg_version = readString(ini, "HK_GENERATOR", "Generator_version", ""), | |
| 276 | + with db_SHA1 = readString(ini, "DB_MODEL", "SHA1", "N/A"), | |
| 277 | + with version = readString(ini, "DB_MODEL", "Version", "0.0.0.0"), | |
| 278 | + with app_name = readString(ini, "DB_MODEL", "app_name", ""), | |
| 279 | + with hk_db_engine = to_HK_DB_engine(readString(ini, "DB_MODEL", "engine", "sqlite3")), | |
| 280 | + with hkg_version = readString(ini, "HK_GENERATOR", "Generator_version", ""), | |
| 281 | + with always_generate = readBool(ini, "HK_GENERATOR", "always_generate", false), | |
| 273 | 282 | |
| 274 | 283 | println("Saved DB model SHA1 = "+db_SHA1); |
| 275 | - with current_db_SHA1 = to_ascii(sha1(serialize(db)+to_byte_array(version))), | |
| 284 | + with current_db_SHA1 = to_ascii(sha1(serialize(db)+to_byte_array(version)+serialize(hk_db_engine))), | |
| 276 | 285 | println("Current DB model SHA1 = "+current_db_SHA1); |
| 277 | 286 | |
| 278 | - if db_SHA1 = current_db_SHA1 & hkg_version = product_numerical_version then | |
| 287 | + if always_generate = false & db_SHA1 = current_db_SHA1 & hkg_version = product_numerical_version then | |
| 279 | 288 | success(println("Model already generated, nothing to do")) |
| 280 | 289 | else if check_database(db) is |
| 281 | 290 | { |
| 282 | 291 | failure then println("Check database error");failure, |
| 283 | - success(database) then | |
| 292 | + success(database) then | |
| 293 | + (if always_generate then println("Always generate flag = True") else unique ); | |
| 294 | + | |
| 284 | 295 | since database is hk_database(name, apps), |
| 285 | - println("Generating models for Database "+name); | |
| 286 | - make_all_tables(apps, destination_dir, use_densaku); | |
| 296 | + println("Generating models for Database '"+name+"' for db engine ["+to_String(hk_db_engine)+"]"); | |
| 297 | + make_all_tables(apps, destination_dir, hk_db_engine, use_densaku); | |
| 287 | 298 | println("Generating VTM for Database "+name); |
| 288 | - make_vtm(apps, destination_dir); | |
| 299 | + make_vtm(apps, hk_db_engine, destination_dir); | |
| 289 | 300 | println("Generating create for Database "+name); |
| 290 | - if generate_create_table(app_name, apps, destination_dir, version, current_db_SHA1) is failure then println("failure");failure else | |
| 301 | + if generate_create_table(app_name, apps, destination_dir, hk_db_engine, version, current_db_SHA1) is failure then println("failure");failure else | |
| 291 | 302 | println("Generating to current version file"); |
| 292 | 303 | if generate_to_current_file(destination_dir, version) is failure then println("can't create to_current file"); failure else |
| 293 | 304 | println("Generating menu for Database "+name); | ... | ... |
src/generation/types.anubis
| ... | ... | @@ -72,8 +72,8 @@ define List(String) |
| 72 | 72 | { |
| 73 | 73 | [] then reverse(so_far), |
| 74 | 74 | [h . t ] then |
| 75 | - since h is hk_column(name, col_type, _, _), | |
| 76 | - _generate_get_default(t, [ to_Anubis_default(col_type) . so_far]) | |
| 75 | + since h is hk_column(name, col_type, attributes, _), | |
| 76 | + _generate_get_default(t, [ to_Anubis_default(col_type, attributes) . so_far]) | |
| 77 | 77 | }. |
| 78 | 78 | |
| 79 | 79 | public define Maybe(One) | ... | ... |
src/generation/web_args.anubis
| ... | ... | @@ -69,29 +69,31 @@ define (List(String), Int) |
| 69 | 69 | public define String |
| 70 | 70 | from_web_arg_to_type_with_default |
| 71 | 71 | ( |
| 72 | - HK_Model_Field col_type, | |
| 73 | - String name | |
| 72 | + HK_Model_Column column | |
| 73 | + //HK_Model_Field col_type, | |
| 74 | + //String name | |
| 74 | 75 | ) = |
| 76 | + since column is hk_column(name, col_type, col_attributes, help), | |
| 75 | 77 | if col_type is |
| 76 | 78 | { |
| 77 | 79 | //anubis(_T) then "constant_byte_array(0,0)", |
| 78 | 80 | p_key then "get_DB_id(lwa, __prefix__+\""+name+"\"),", |
| 79 | 81 | //binary then "constant_byte_array(0,0)", |
| 80 | - boolean_field then "get_Bool(lwa, __prefix__+\""+name+"\"),", | |
| 81 | - date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," else "get_dummy_DB_date,", | |
| 82 | - time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," else "get_dummy_DB_time,", | |
| 83 | - datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," else "get_dummy_DB_datetime,", | |
| 82 | + boolean_field then "get_Bool(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 83 | + date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+")," else "get_dummy_DB_date,", | |
| 84 | + time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+")," else "get_dummy_DB_time,", | |
| 85 | + datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+")," else "get_dummy_DB_datetime,", | |
| 84 | 86 | foreign_key(_,_,_,_,_) then "get_DB_id(lwa, __prefix__+\""+name+"\"),", |
| 85 | - integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 86 | - float_field then "get_Float(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 87 | - char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 88 | - password_field(min_size) then "if get_Password(lwa, __prefix__+\""+name+"_1\", __prefix__+\""+name+"_2\") is { failure then "+to_Anubis_default(col_type)+", success(pass) then pass},", | |
| 89 | - text_field(_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 90 | - color_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 91 | - phone_field(_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 87 | + integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 88 | + float_field then "get_Float(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 89 | + char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 90 | + password_field(min_size) then "if get_Password(lwa, __prefix__+\""+name+"_1\", __prefix__+\""+name+"_2\") is { failure then "+to_Anubis_default(col_type, col_attributes)+", success(pass) then pass},", | |
| 91 | + text_field(_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 92 | + color_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 93 | + phone_field(_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 92 | 94 | // mobile_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", |
| 93 | - url_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | |
| 94 | - email_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," | |
| 95 | + url_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+"),", | |
| 96 | + email_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type, col_attributes)+")," | |
| 95 | 97 | }. |
| 96 | 98 | |
| 97 | 99 | define List(String) |
| ... | ... | @@ -106,8 +108,8 @@ define List(String) |
| 106 | 108 | { |
| 107 | 109 | [] then reverse(so_far), |
| 108 | 110 | [h . t ] then |
| 109 | - since h is hk_column(name, col_type, _, _), | |
| 110 | - with result = from_web_arg_to_type_with_default(col_type, name), | |
| 111 | + //since h is hk_column(name, col_type, _, _), | |
| 112 | + with result = from_web_arg_to_type_with_default(h), | |
| 111 | 113 | //If the field is not editable no need to get it from the web |
| 112 | 114 | _generate_extract_web_arg_to_type_with_default(t, [ " "+result . so_far]) |
| 113 | 115 | ... | ... |
src/main.anubis
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | * |
| 4 | 4 | * *Title* Interfacing, generating and controling a database with Anubis |
| 5 | 5 | * |
| 6 | - * *Copyright* Copyright © David René 2015-2019. | |
| 6 | + * *Copyright* Copyright © David René 2015-2025. | |
| 7 | 7 | * |
| 8 | 8 | * |
| 9 | 9 | * |
| ... | ... | @@ -21,14 +21,14 @@ read model.3.0.0.anubis |
| 21 | 21 | read system/muscle.anubis |
| 22 | 22 | |
| 23 | 23 | global define One |
| 24 | - hayamiki_1_19 | |
| 24 | + hayamiki_1_19_test | |
| 25 | 25 | ( |
| 26 | 26 | List(String) args |
| 27 | 27 | ) = |
| 28 | 28 | if load_hk_generator_1_19 is |
| 29 | 29 | { |
| 30 | 30 | failure then println("Hayamiki generator 1.19 can't be load"), |
| 31 | - success(hk_gen) then forget(hk_gen.generate_model_files(the_database_description, "", true)) | |
| 31 | + success(hk_gen) then forget(hk_gen.generate_model_files(the_database_description, "D:\Documents and Settings\david\Mes documents\my_anubis\hk_test", true)) | |
| 32 | 32 | }. |
| 33 | 33 | |
| 34 | 34 | global define One | ... | ... |
src/web_controller/hayamiki.anubis
| ... | ... | @@ -68,7 +68,7 @@ public define WEB_Controller_Result |
| 68 | 68 | String lang, |
| 69 | 69 | List(Web_arg) lwa, |
| 70 | 70 | String table, |
| 71 | - String edit_view_name, | |
| 71 | + String edit_view_name, //Editor to use | |
| 72 | 72 | HK_Form_action action, |
| 73 | 73 | VTM vtm, |
| 74 | 74 | String clause, |
| ... | ... | @@ -77,11 +77,11 @@ public define WEB_Controller_Result |
| 77 | 77 | ) = |
| 78 | 78 | |
| 79 | 79 | with dialog_id = get_String(lwa, "dialog_id", "edit_table_dlg_ajax"), |
| 80 | -// println("compute_ajax_edit_table_entry_page: table["+table+"] edit_view_name ["+edit_view_name+"] dialog_id ["+dialog_id+"]"); | |
| 81 | -// println("clause ["+clause+"] fk_clause["+fk_clause+"]"); | |
| 80 | + println("compute_ajax_edit_table_entry_page: table["+table+"] edit_view_name ["+edit_view_name+"] dialog_id ["+dialog_id+"]"); | |
| 81 | + println("clause ["+clause+"] fk_clause["+fk_clause+"]"); | |
| 82 | 82 | |
| 83 | 83 | |
| 84 | - if edit_table_content(db, _T, lang, /*web_site_directory,*/ lwa, /*dialog_id,*/ table, edit_view_name, action, vtm, /*clause,*/ fk_clause, referer) is | |
| 84 | + if edit_table_content(db, _T, lang, lwa, /*dialog_id,*/ table, edit_view_name, action, vtm, /*clause,*/ fk_clause, referer) is | |
| 85 | 85 | { |
| 86 | 86 | failure then |
| 87 | 87 | redirect_to_previous, //compute_page_error(tb, http_ok, error("TABLE_EDITOR_DOESNT_EXIST")), |
| ... | ... | @@ -561,9 +561,9 @@ define (WEB_Session) -> WEB_Controller_Result |
| 561 | 561 | // println("_filter name: "+_filter.filter_name); |
| 562 | 562 | // println("_filter query: "+_filter.filter_string); |
| 563 | 563 | // with clause = if _filter.filter_string = "" then "" else if _clause = "" then _filter.filter_string else "("+_filter.filter_string+") AND "+_clause, |
| 564 | - println("get_rows_json final clause : ["+clause+"])"); | |
| 564 | +// println("get_rows_json final clause : ["+clause+"])"); | |
| 565 | 565 | with referer_count = if referer is {no_referer then "", hk_referer(_, row_id, _, column) then (if clause = "" then "" else " AND ")+column+"="+row_id}, |
| 566 | - println("referer_count ["+referer_count+"]"); | |
| 566 | +// println("referer_count ["+referer_count+"]"); | |
| 567 | 567 | // with number = controller.get_count(db, if clause = "" then "" else "WHERE "+ clause + referer_count), |
| 568 | 568 | with number = controller.get_count(db, if clause = "" & referer_count = "" then "" else " WHERE "+ clause + referer_count), |
| 569 | 569 | |
| ... | ... | @@ -792,16 +792,16 @@ define (WEB_Session) -> WEB_Controller_Result |
| 792 | 792 | with oper = get_String(lwa, "oper", "N/A"), |
| 793 | 793 | |
| 794 | 794 | if oper = "create" then |
| 795 | - logger(logInfo, "crud: CREATE operation requested"); | |
| 795 | + //logger(logInfo, "crud: CREATE operation requested"); | |
| 796 | 796 | update_row(db, _vtm, logger)(_session) |
| 797 | 797 | else if oper = "read" then |
| 798 | - logger(logInfo, "crud: READ operation requested"); | |
| 798 | + //logger(logInfo, "crud: READ operation requested"); | |
| 799 | 799 | get_rows_json(db, _vtm)(_session) |
| 800 | 800 | else if oper = "update" then |
| 801 | - logger(logInfo, "crud: UPDATE operation requested"); | |
| 801 | + //logger(logInfo, "crud: UPDATE operation requested"); | |
| 802 | 802 | update_row(db, _vtm, logger)(_session) |
| 803 | 803 | else if oper = "delete" then |
| 804 | - logger(logInfo, "crud: DELETE operation requested"); | |
| 804 | + //logger(logInfo, "crud: DELETE operation requested"); | |
| 805 | 805 | delete_row(db, _vtm, logger)(_session) |
| 806 | 806 | else |
| 807 | 807 | set_Page_Message(_session.fields, error_translate("CRUD OPERATION_NOT_FOUND")); | ... | ... |