Commit b28ba961e9282007fd128ad1e1ee8d1d8b286431
1 parent
e02dec72
add support of Foreign key constraint "on delete" and "on update"
Showing
17 changed files
with
103 additions
and
30 deletions
Show diff stats
ds_files/graphviz.gv
| 1 | /* | 1 | /* |
| 2 | * Created by 伝作 (Densaku). | 2 | * Created by 伝作 (Densaku). |
| 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) | 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) |
| 4 | - * Date: 2017-09-16 | ||
| 5 | - * Time: 09:48:18 | 4 | + * Date: 2018-11-10 |
| 5 | + * Time: 17:14:38 | ||
| 6 | * | 6 | * |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| @@ -159,6 +159,7 @@ digraph DS { | @@ -159,6 +159,7 @@ digraph DS { | ||
| 159 | <TR><TD ALIGN="LEFT"><B><FONT COLOR="mediumblue">HK_App_Name</FONT></B></TD><TD ALIGN="LEFT" PORT="foreign_key_app_name" >app_name</TD></TR> | 159 | <TR><TD ALIGN="LEFT"><B><FONT COLOR="mediumblue">HK_App_Name</FONT></B></TD><TD ALIGN="LEFT" PORT="foreign_key_app_name" >app_name</TD></TR> |
| 160 | <TR><TD ALIGN="LEFT"><B><FONT COLOR="darkviolet">String</FONT></B></TD><TD ALIGN="LEFT" PORT="foreign_key_table_name" >table_name</TD></TR> | 160 | <TR><TD ALIGN="LEFT"><B><FONT COLOR="darkviolet">String</FONT></B></TD><TD ALIGN="LEFT" PORT="foreign_key_table_name" >table_name</TD></TR> |
| 161 | <TR><TD ALIGN="LEFT"><B><FONT COLOR="darkviolet">List</FONT>(<FONT COLOR="darkviolet">String</FONT>)</B></TD><TD ALIGN="LEFT" PORT="foreign_key_searchable_fields" >searchable_fields</TD></TR> | 161 | <TR><TD ALIGN="LEFT"><B><FONT COLOR="darkviolet">List</FONT>(<FONT COLOR="darkviolet">String</FONT>)</B></TD><TD ALIGN="LEFT" PORT="foreign_key_searchable_fields" >searchable_fields</TD></TR> |
| 162 | + <TR><TD ALIGN="LEFT"><B><FONT COLOR="darkviolet">List</FONT>(<FONT COLOR="mediumblue">HK_Foreign_Key_Clause</FONT>)</B></TD><TD ALIGN="LEFT" PORT="foreign_key_hk_fk_clause" >hk_fk_clause</TD></TR> | ||
| 162 | <TR><TD COLSPAN="2" VALIGN="MIDDLE" ALIGN="LEFT"><FONT COLOR="orangered"><B>)</B></FONT></TD></TR> | 163 | <TR><TD COLSPAN="2" VALIGN="MIDDLE" ALIGN="LEFT"><FONT COLOR="orangered"><B>)</B></FONT></TD></TR> |
| 163 | 164 | ||
| 164 | <TR><TD COLSPAN="2" PORT="alt:integer_field" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>integer_field (</B></FONT></TD></TR> | 165 | <TR><TD COLSPAN="2" PORT="alt:integer_field" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>integer_field (</B></FONT></TD></TR> |
| @@ -198,6 +199,7 @@ digraph DS { | @@ -198,6 +199,7 @@ digraph DS { | ||
| 198 | HK_Model_Field:char_field_choices -> HK_Text_Choices:TYPE | 199 | HK_Model_Field:char_field_choices -> HK_Text_Choices:TYPE |
| 199 | HK_Model_Field:integer_field_choices -> HK_Int_Choices:TYPE | 200 | HK_Model_Field:integer_field_choices -> HK_Int_Choices:TYPE |
| 200 | HK_Model_Field:foreign_key_app_name -> HK_App_Name:TYPE | 201 | HK_Model_Field:foreign_key_app_name -> HK_App_Name:TYPE |
| 202 | + HK_Model_Field:foreign_key_hk_fk_clause -> HK_Foreign_Key_Clause:TYPE | ||
| 201 | HK_Model_Field:datetime_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE | 203 | HK_Model_Field:datetime_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE |
| 202 | HK_Model_Field:time_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE | 204 | HK_Model_Field:time_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE |
| 203 | HK_Model_Field:date_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE | 205 | HK_Model_Field:date_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE |
| @@ -216,6 +218,44 @@ digraph DS { | @@ -216,6 +218,44 @@ digraph DS { | ||
| 216 | 218 | ||
| 217 | 219 | ||
| 218 | 220 | ||
| 221 | + HK_Foreign_Key_Clause_On_Directive [ label=< | ||
| 222 | + <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2" BGCOLOR="gray95"> | ||
| 223 | + <TR><TD COLSPAN="2" PORT="TYPE" VALIGN="MIDDLE" ALIGN="CENTER" BGCOLOR="lightblue" ><FONT COLOR="mediumblue"><B>HK_Foreign_Key_Clause_On_Directive</B></FONT></TD></TR> | ||
| 224 | + | ||
| 225 | + <TR><TD COLSPAN="2" PORT="alt:set_null" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>set_null</B></FONT></TD></TR> | ||
| 226 | + | ||
| 227 | + <TR><TD COLSPAN="2" PORT="alt:set_default" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>set_default</B></FONT></TD></TR> | ||
| 228 | + | ||
| 229 | + <TR><TD COLSPAN="2" PORT="alt:cascade" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>cascade</B></FONT></TD></TR> | ||
| 230 | + | ||
| 231 | + <TR><TD COLSPAN="2" PORT="alt:restrict" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>restrict</B></FONT></TD></TR> | ||
| 232 | + | ||
| 233 | + <TR><TD COLSPAN="2" PORT="alt:no_action" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>no_action</B></FONT></TD></TR> | ||
| 234 | + | ||
| 235 | + </TABLE> | ||
| 236 | + >]; | ||
| 237 | + | ||
| 238 | + | ||
| 239 | + | ||
| 240 | + HK_Foreign_Key_Clause [ label=< | ||
| 241 | + <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2" BGCOLOR="gray95"> | ||
| 242 | + <TR><TD COLSPAN="2" PORT="TYPE" VALIGN="MIDDLE" ALIGN="CENTER" BGCOLOR="lightblue" ><FONT COLOR="mediumblue"><B>HK_Foreign_Key_Clause</B></FONT></TD></TR> | ||
| 243 | + | ||
| 244 | + <TR><TD COLSPAN="2" PORT="alt:on_delete" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>on_delete (</B></FONT></TD></TR> | ||
| 245 | + <TR><TD ALIGN="LEFT"><B><FONT COLOR="mediumblue">HK_Foreign_Key_Clause_On_Directive</FONT></B></TD><TD ALIGN="LEFT" PORT="on_delete_on_delete" >on_delete</TD></TR> | ||
| 246 | + <TR><TD COLSPAN="2" VALIGN="MIDDLE" ALIGN="LEFT"><FONT COLOR="orangered"><B>)</B></FONT></TD></TR> | ||
| 247 | + | ||
| 248 | + <TR><TD COLSPAN="2" PORT="alt:on_update" VALIGN="MIDDLE" BGCOLOR="bisque" ALIGN="LEFT"><FONT COLOR="orangered"><B>on_update (</B></FONT></TD></TR> | ||
| 249 | + <TR><TD ALIGN="LEFT"><B><FONT COLOR="mediumblue">HK_Foreign_Key_Clause_On_Directive</FONT></B></TD><TD ALIGN="LEFT" PORT="on_update_on_update" >on_update</TD></TR> | ||
| 250 | + <TR><TD COLSPAN="2" VALIGN="MIDDLE" ALIGN="LEFT"><FONT COLOR="orangered"><B>)</B></FONT></TD></TR> | ||
| 251 | + | ||
| 252 | + </TABLE> | ||
| 253 | + >]; | ||
| 254 | + | ||
| 255 | + HK_Foreign_Key_Clause:on_update_on_update -> HK_Foreign_Key_Clause_On_Directive:TYPE | ||
| 256 | + HK_Foreign_Key_Clause:on_delete_on_delete -> HK_Foreign_Key_Clause_On_Directive:TYPE | ||
| 257 | + | ||
| 258 | + | ||
| 219 | HK_Int_Choices [ label=< | 259 | HK_Int_Choices [ label=< |
| 220 | <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2" BGCOLOR="gray95"> | 260 | <TABLE BORDER="1" CELLBORDER="0" CELLSPACING="0" CELLPADDING="2" BGCOLOR="gray95"> |
| 221 | <TR><TD COLSPAN="2" PORT="TYPE" VALIGN="MIDDLE" ALIGN="CENTER" BGCOLOR="lightblue" ><FONT COLOR="mediumblue"><B>HK_Int_Choices</B></FONT></TD></TR> | 261 | <TR><TD COLSPAN="2" PORT="TYPE" VALIGN="MIDDLE" ALIGN="CENTER" BGCOLOR="lightblue" ><FONT COLOR="mediumblue"><B>HK_Int_Choices</B></FONT></TD></TR> |
| 1 | + | ||
| 2 | +Microsoft Visual Studio Solution File, Format Version 9.00 | ||
| 3 | +# Visual Studio 2005 | ||
| 4 | +# SharpDevelop 1.0.12.108 | ||
| 5 | +Project("{B6712916-30DE-4a3e-A54C-2A79AC984AEE}") = "hayamiki_ds_types", "hayamiki_ds_types.aproj", "{06BE5572-9B4A-4F41-A01E-84C730A8F4E4}" | ||
| 6 | +EndProject | ||
| 7 | +Global | ||
| 8 | + GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| 9 | + Debug|Any CPU = Debug|Any CPU | ||
| 10 | + Release|Any CPU = Release|Any CPU | ||
| 11 | + EndGlobalSection | ||
| 12 | + GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| 13 | + {06BE5572-9B4A-4F41-A01E-84C730A8F4E4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| 14 | + {06BE5572-9B4A-4F41-A01E-84C730A8F4E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 15 | + {06BE5572-9B4A-4F41-A01E-84C730A8F4E4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| 16 | + {06BE5572-9B4A-4F41-A01E-84C730A8F4E4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| 17 | + EndGlobalSection | ||
| 18 | +EndGlobal |
hayamiki_generator.aproj
| @@ -147,6 +147,8 @@ | @@ -147,6 +147,8 @@ | ||
| 147 | <Compile Include="hayamiki_lib\model\types\hk_constraint.anubis" /> | 147 | <Compile Include="hayamiki_lib\model\types\hk_constraint.anubis" /> |
| 148 | <Compile Include="hayamiki_lib\model\types\hk_database.anubis" /> | 148 | <Compile Include="hayamiki_lib\model\types\hk_database.anubis" /> |
| 149 | <Compile Include="hayamiki_lib\model\types\hk_datetime_field_attr.anubis" /> | 149 | <Compile Include="hayamiki_lib\model\types\hk_datetime_field_attr.anubis" /> |
| 150 | + <Compile Include="hayamiki_lib\model\types\hk_foreign_key_clause.anubis" /> | ||
| 151 | + <Compile Include="hayamiki_lib\model\types\hk_foreign_key_clause_on_directive.anubis" /> | ||
| 150 | <Compile Include="hayamiki_lib\model\types\hk_help_text.anubis" /> | 152 | <Compile Include="hayamiki_lib\model\types\hk_help_text.anubis" /> |
| 151 | <Compile Include="hayamiki_lib\model\types\hk_icon.anubis" /> | 153 | <Compile Include="hayamiki_lib\model\types\hk_icon.anubis" /> |
| 152 | <Compile Include="hayamiki_lib\model\types\hk_int_choice.anubis" /> | 154 | <Compile Include="hayamiki_lib\model\types\hk_int_choice.anubis" /> |
hayamiki_lib @ 6b95d3a55ad
src/check.anubis
| @@ -42,7 +42,7 @@ define Maybe(HK_Model_Column) | @@ -42,7 +42,7 @@ define Maybe(HK_Model_Column) | ||
| 42 | HK_Model_Column col | 42 | HK_Model_Column col |
| 43 | )= | 43 | )= |
| 44 | since col is hk_column(name, type, attrib, help), | 44 | since col is hk_column(name, type, attrib, help), |
| 45 | - if type is foreign_key(fk_app, fk_table, fields) then | 45 | + if type is foreign_key(fk_app, fk_table, fields, fk_clause) then |
| 46 | //TODO check for searchable fields if exists in foreign table | 46 | //TODO check for searchable fields if exists in foreign table |
| 47 | with mb_fk_app = if (fk_app) is | 47 | with mb_fk_app = if (fk_app) is |
| 48 | { | 48 | { |
| @@ -59,7 +59,7 @@ define Maybe(HK_Model_Column) | @@ -59,7 +59,7 @@ define Maybe(HK_Model_Column) | ||
| 59 | if mb_fk_app is | 59 | if mb_fk_app is |
| 60 | { | 60 | { |
| 61 | failure then failure, | 61 | failure then failure, |
| 62 | - success(n_fk_app) then success(hk_column(name, foreign_key(if (fk_app) is app_name(_) then app_name(n_fk_app) else fk_app, (if length(n_fk_app)>0 then n_fk_app+"_"else "")+fk_table, fields), attrib, help)) | 62 | + success(n_fk_app) then success(hk_column(name, foreign_key(if (fk_app) is app_name(_) then app_name(n_fk_app) else fk_app, (if length(n_fk_app)>0 then n_fk_app+"_"else "")+fk_table, fields, fk_clause), attrib, help)) |
| 63 | } | 63 | } |
| 64 | else | 64 | else |
| 65 | success(col). | 65 | success(col). |
src/generation/columns.anubis
| @@ -156,7 +156,7 @@ public define Maybe(String) | @@ -156,7 +156,7 @@ public define Maybe(String) | ||
| 156 | auto_now_add then | 156 | auto_now_add then |
| 157 | if insert then success(name) else failure | 157 | if insert then success(name) else failure |
| 158 | }, | 158 | }, |
| 159 | - foreign_key(_,_,_) then success(name), | 159 | + foreign_key(_,_,_,_) then success(name), |
| 160 | integer_field(_) then success(name), | 160 | integer_field(_) then success(name), |
| 161 | float_field then success(name), | 161 | float_field then success(name), |
| 162 | char_field(_,_) then success(name), | 162 | char_field(_,_) then success(name), |
| @@ -251,7 +251,7 @@ public define Maybe(String) | @@ -251,7 +251,7 @@ public define Maybe(String) | ||
| 251 | auto_now then success("information(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+".datetime, 18, "+to_Anubis_source(help)+")"), | 251 | auto_now then success("information(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+".datetime, 18, "+to_Anubis_source(help)+")"), |
| 252 | auto_now_add then success("information(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+".datetime, 18, "+to_Anubis_source(help)+")") | 252 | auto_now_add then success("information(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+".datetime, 18, "+to_Anubis_source(help)+")") |
| 253 | }, | 253 | }, |
| 254 | - foreign_key(app,foreign_table,fields) then | 254 | + foreign_key(app,foreign_table,fields,_) then |
| 255 | if length(fields) = 0 then | 255 | if length(fields) = 0 then |
| 256 | success("foreign_text(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", \""+foreign_table+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")") | 256 | success("foreign_text(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", \""+foreign_table+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")") |
| 257 | else | 257 | else |
| @@ -334,7 +334,7 @@ public define String | @@ -334,7 +334,7 @@ public define String | ||
| 334 | date_field(attrs) then "to_String("+current_type_name+"."+name+")", | 334 | date_field(attrs) then "to_String("+current_type_name+"."+name+")", |
| 335 | time_field(attrs) then "to_String("+current_type_name+"."+name+")", | 335 | time_field(attrs) then "to_String("+current_type_name+"."+name+")", |
| 336 | datetime_field(attrs) then "to_String("+current_type_name+"."+name+")" | 336 | datetime_field(attrs) then "to_String("+current_type_name+"."+name+")" |
| 337 | - foreign_key(app,foreign_table,_) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", | 337 | + foreign_key(app,foreign_table,_,_) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")", |
| 338 | integer_field(_) then "to_String("+current_type_name+"."+name+")", | 338 | integer_field(_) then "to_String("+current_type_name+"."+name+")", |
| 339 | float_field then "float_to_string("+current_type_name+"."+name+",5)", | 339 | float_field then "float_to_string("+current_type_name+"."+name+",5)", |
| 340 | char_field(_,_) then current_type_name+"."+name, | 340 | char_field(_,_) then current_type_name+"."+name, |
src/generation/create_table.anubis
| @@ -116,7 +116,7 @@ define String | @@ -116,7 +116,7 @@ define String | ||
| 116 | "public define String create_table_"+name+" =\n"+ | 116 | "public define String create_table_"+name+" =\n"+ |
| 117 | "\"CREATE TABLE "+name+" (\n"+ | 117 | "\"CREATE TABLE "+name+" (\n"+ |
| 118 | //columns | 118 | //columns |
| 119 | - " "+create_table_generate_columns([hk_column("id",p_key) . columns], " ")+ | 119 | + " "+create_table_generate_columns([hk_column("id", p_key) . columns], " ")+ |
| 120 | create_table_generate_constraints(constraints, " ")+ | 120 | create_table_generate_constraints(constraints, " ")+ |
| 121 | "\n)\".\n" | 121 | "\n)\".\n" |
| 122 | . | 122 | . |
src/generation/extractor.anubis
| @@ -25,7 +25,7 @@ public define String | @@ -25,7 +25,7 @@ public define String | ||
| 25 | date_field(_) then "db_date(text"+cursor_index+")", | 25 | date_field(_) then "db_date(text"+cursor_index+")", |
| 26 | time_field(_) then "db_time(text"+cursor_index+")", | 26 | time_field(_) then "db_time(text"+cursor_index+")", |
| 27 | datetime_field(_) then "db_datetime(text"+cursor_index+")", | 27 | datetime_field(_) then "db_datetime(text"+cursor_index+")", |
| 28 | - foreign_key(_,_,_) then "db_id((Int)db_integer"+cursor_index+")", | 28 | + foreign_key(_,_,_,_) then "db_id((Int)db_integer"+cursor_index+")", |
| 29 | integer_field(_) then "(Int)db_integer"+cursor_index, | 29 | integer_field(_) then "(Int)db_integer"+cursor_index, |
| 30 | float_field then "db_float"+cursor_index, | 30 | float_field then "db_float"+cursor_index, |
| 31 | char_field(_,_) then "text"+cursor_index, | 31 | char_field(_,_) then "text"+cursor_index, |
src/generation/fields.anubis
| @@ -30,7 +30,7 @@ public define String | @@ -30,7 +30,7 @@ public define String | ||
| 30 | date_field(_) then "DB_date", | 30 | date_field(_) then "DB_date", |
| 31 | time_field(_) then "DB_time", | 31 | time_field(_) then "DB_time", |
| 32 | datetime_field(_) then "DB_datetime", | 32 | datetime_field(_) then "DB_datetime", |
| 33 | - foreign_key(_,_,_) then "DB_id", | 33 | + foreign_key(_,_,_,_) then "DB_id", |
| 34 | integer_field(_) then "Int", | 34 | integer_field(_) then "Int", |
| 35 | float_field then "Float", | 35 | float_field then "Float", |
| 36 | char_field(_,_) then "String", | 36 | char_field(_,_) then "String", |
| @@ -56,7 +56,7 @@ public define String | @@ -56,7 +56,7 @@ public define String | ||
| 56 | date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")", | 56 | date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")", |
| 57 | time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")", | 57 | time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")", |
| 58 | datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")", | 58 | datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")", |
| 59 | - foreign_key(_,_,_) then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", | 59 | + foreign_key(_,_,_,_) then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")", |
| 60 | integer_field(_) then "int", | 60 | integer_field(_) then "int", |
| 61 | float_field then "float", | 61 | float_field then "float", |
| 62 | char_field(_,_) then "string", | 62 | char_field(_,_) then "string", |
| @@ -78,7 +78,7 @@ public define String | @@ -78,7 +78,7 @@ public define String | ||
| 78 | if t is | 78 | if t is |
| 79 | { | 79 | { |
| 80 | //anubis(_T) then "ByteArray", | 80 | //anubis(_T) then "ByteArray", |
| 81 | - p_key then fill("INTEGER", 15) + (if name = "id" then " PRIMARY KEY" else ""), | 81 | + p_key then fill("INTEGER", 15) + (if name = "id" then " PRIMARY KEY AUTOINCREMENT" else ""), |
| 82 | boolean_field then fill("BOOL", 15) + format_attributes(attributes), | 82 | boolean_field then fill("BOOL", 15) + format_attributes(attributes), |
| 83 | date_field(dt_attrs) then | 83 | date_field(dt_attrs) then |
| 84 | with new_attributes = if dt_attrs is auto_now_add then [default("(date('now', 'LOCALTIME'))")] else attributes, | 84 | with new_attributes = if dt_attrs is auto_now_add then [default("(date('now', 'LOCALTIME'))")] else attributes, |
| @@ -89,7 +89,7 @@ public define String | @@ -89,7 +89,7 @@ public define String | ||
| 89 | datetime_field(dt_attrs) then | 89 | datetime_field(dt_attrs) then |
| 90 | with new_attributes = if dt_attrs is auto_now_add then [default("(datetime('now', 'LOCALTIME'))")] else attributes, | 90 | with new_attributes = if dt_attrs is auto_now_add then [default("(datetime('now', 'LOCALTIME'))")] else attributes, |
| 91 | fill("DATETIME", 15) + format_attributes(new_attributes), | 91 | fill("DATETIME", 15) + format_attributes(new_attributes), |
| 92 | - foreign_key(app,fk,_) then fill("INTEGER", 15) + format_attributes(attributes)+" REFERENCES "+fk+"(id) ", | 92 | + foreign_key(app,fk,_,fk_clause) then fill("INTEGER", 15) + format_attributes(attributes)+" REFERENCES "+fk+"(id) "+format_fk_clause(fk_clause), |
| 93 | integer_field(_) then fill("INTEGER", 15) + format_attributes(attributes), | 93 | integer_field(_) then fill("INTEGER", 15) + format_attributes(attributes), |
| 94 | float_field then fill("DOUBLE", 15) + format_attributes(attributes), | 94 | float_field then fill("DOUBLE", 15) + format_attributes(attributes), |
| 95 | char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), | 95 | char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes), |
| @@ -116,7 +116,7 @@ public define String | @@ -116,7 +116,7 @@ public define String | ||
| 116 | date_field(_) then "db_date(\"\")", | 116 | date_field(_) then "db_date(\"\")", |
| 117 | time_field(_) then "db_time(\"\")", | 117 | time_field(_) then "db_time(\"\")", |
| 118 | datetime_field(_) then "db_datetime(\"\")", | 118 | datetime_field(_) then "db_datetime(\"\")", |
| 119 | - foreign_key(_,_,_) then "(DB_id)none", | 119 | + foreign_key(_,_,_,_) then "(DB_id)none", |
| 120 | integer_field(_) then "(Int)0", | 120 | integer_field(_) then "(Int)0", |
| 121 | float_field then "(Float)0.0", | 121 | float_field then "(Float)0.0", |
| 122 | char_field(choices,size) then "\"\"", | 122 | char_field(choices,size) then "\"\"", |
| @@ -161,7 +161,7 @@ public define String | @@ -161,7 +161,7 @@ public define String | ||
| 161 | else | 161 | else |
| 162 | "" | 162 | "" |
| 163 | }, | 163 | }, |
| 164 | - foreign_key(_,_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")", | 164 | + foreign_key(_,_,_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")", |
| 165 | integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", | 165 | integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")", |
| 166 | float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", | 166 | float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")", |
| 167 | char_field(_,_) then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", | 167 | char_field(_,_) then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")", |
src/generation/header.anubis
| @@ -22,7 +22,7 @@ define Maybe(One) | @@ -22,7 +22,7 @@ define Maybe(One) | ||
| 22 | [] then success(unique), | 22 | [] then success(unique), |
| 23 | [h . t] then | 23 | [h . t] then |
| 24 | since h is hk_column(_, type, _, _), | 24 | since h is hk_column(_, type, _, _), |
| 25 | - if type is foreign_key(app, table_name, _) then | 25 | + if type is foreign_key(app, table_name, _, _) then |
| 26 | if write_string(stream, "\nread database/generated/"+table_name+".anubis") is | 26 | if write_string(stream, "\nread database/generated/"+table_name+".anubis") is |
| 27 | { | 27 | { |
| 28 | failure then failure, | 28 | failure then failure, |
src/generation/html.anubis
| @@ -98,7 +98,7 @@ public define String | @@ -98,7 +98,7 @@ public define String | ||
| 98 | date_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), | 98 | date_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), |
| 99 | time_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), | 99 | time_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), |
| 100 | datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), | 100 | datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name), |
| 101 | - foreign_key(app, foreign_table,_) then to_HTML_cell_text(column, data_name, general_type_name), | 101 | + foreign_key(app, foreign_table,_,_) then to_HTML_cell_text(column, data_name, general_type_name), |
| 102 | integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), | 102 | integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name), |
| 103 | float_field then to_HTML_cell_text(column, data_name, general_type_name), | 103 | float_field then to_HTML_cell_text(column, data_name, general_type_name), |
| 104 | char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), | 104 | char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name), |
src/generation/icons.anubis
| @@ -28,7 +28,7 @@ public define String | @@ -28,7 +28,7 @@ public define String | ||
| 28 | date_field(attrs) then icn16_clock, | 28 | date_field(attrs) then icn16_clock, |
| 29 | time_field(attrs) then icn16_clock, | 29 | time_field(attrs) then icn16_clock, |
| 30 | datetime_field(attrs) then icn16_clock, | 30 | datetime_field(attrs) then icn16_clock, |
| 31 | - foreign_key(app,foreign_table,_) then icn16_question, | 31 | + foreign_key(app,foreign_table,_,_) then icn16_question, |
| 32 | integer_field(choice) then icn16_question, | 32 | integer_field(choice) then icn16_question, |
| 33 | float_field then icn16_question, | 33 | float_field then icn16_question, |
| 34 | char_field(choice, size) then icn16_question, | 34 | char_field(choice, size) then icn16_question, |
src/generation/json.anubis
| @@ -28,7 +28,7 @@ public define String | @@ -28,7 +28,7 @@ public define String | ||
| 28 | date_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))", | 28 | date_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))", |
| 29 | time_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))", | 29 | time_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))", |
| 30 | datetime_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))", | 30 | datetime_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))", |
| 31 | - foreign_key(app,foreign_table,_) then "to_JSON_String(get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+"))", | 31 | + foreign_key(app,foreign_table,_,_) then "to_JSON_String(get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+"))", |
| 32 | integer_field(_) then current_type_name+"."+name, | 32 | integer_field(_) then current_type_name+"."+name, |
| 33 | float_field then "float_to_string("+current_type_name+"."+name+",5)", | 33 | float_field then "float_to_string("+current_type_name+"."+name+",5)", |
| 34 | char_field(_,_) then "to_JSON_String("+current_type_name+"."+name+")", | 34 | char_field(_,_) then "to_JSON_String("+current_type_name+"."+name+")", |
| @@ -62,7 +62,7 @@ public define String | @@ -62,7 +62,7 @@ public define String | ||
| 62 | date_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", | 62 | date_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| 63 | time_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", | 63 | time_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| 64 | datetime_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", | 64 | datetime_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| 65 | - foreign_key(app,foreign_table,_) then "json_member(\""+name+"\", if resolve_fk then json_string(get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+"))) else json_int("+current_type_name+"."+name+")", | 65 | + foreign_key(app,foreign_table,_,_) then "json_member(\""+name+"\", if resolve_fk then json_string(get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+"))) else json_int("+current_type_name+"."+name+")", |
| 66 | integer_field(_) then "json_member(\""+name+"\", json_int("+current_type_name+"."+name+"))", | 66 | integer_field(_) then "json_member(\""+name+"\", json_int("+current_type_name+"."+name+"))", |
| 67 | float_field then "json_member(\""+name+"\", json_float("+current_type_name+"."+name+",5))", | 67 | float_field then "json_member(\""+name+"\", json_float("+current_type_name+"."+name+",5))", |
| 68 | char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", | 68 | char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))", |
| @@ -92,7 +92,7 @@ public define String | @@ -92,7 +92,7 @@ public define String | ||
| 92 | date_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", | 92 | date_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", |
| 93 | time_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", | 93 | time_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", |
| 94 | datetime_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", | 94 | datetime_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))", |
| 95 | - foreign_key(app,foreign_table,_) then | 95 | + foreign_key(app,foreign_table,_,_) then |
| 96 | " if resolve_fk then\n"+ | 96 | " if resolve_fk then\n"+ |
| 97 | " json_member(\""+name+"\", json_string(get_"+foreign_table+"_show_string(db, db_id((Int)db_integer"+cursor_index+"))))\n"+ | 97 | " json_member(\""+name+"\", json_string(get_"+foreign_table+"_show_string(db, db_id((Int)db_integer"+cursor_index+"))))\n"+ |
| 98 | " else\n"+ | 98 | " else\n"+ |
src/generation/model.anubis
| @@ -24,3 +24,16 @@ public define String | @@ -24,3 +24,16 @@ public define String | ||
| 24 | not_null then "NOT NULL" | 24 | not_null then "NOT NULL" |
| 25 | }, attributes)). | 25 | }, attributes)). |
| 26 | 26 | ||
| 27 | +public define String | ||
| 28 | + format_fk_clause | ||
| 29 | + ( | ||
| 30 | + List(HK_Foreign_Key_Clause) fk_clauses | ||
| 31 | + )= | ||
| 32 | + join(" ",map((HK_Foreign_Key_Clause fk_clause) |-> | ||
| 33 | + if fk_clause is | ||
| 34 | + { | ||
| 35 | + on_delete(directive) then "ON DELETE "+to_String(directive), | ||
| 36 | + on_update(directive) then "ON UPDATE "+to_String(directive) | ||
| 37 | + }, fk_clauses | ||
| 38 | + )) | ||
| 39 | +. |
src/generation/vt_view.anubis
| @@ -49,7 +49,7 @@ define String | @@ -49,7 +49,7 @@ define String | ||
| 49 | date_field(attrs) then "date(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", | 49 | date_field(attrs) then "date(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", |
| 50 | time_field(attrs) then "time(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", | 50 | time_field(attrs) then "time(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", |
| 51 | datetime_field(attrs) then "datetime(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", | 51 | datetime_field(attrs) then "datetime(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", |
| 52 | - foreign_key(app,foreign_table,_) then "foreign_text(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")", | 52 | + foreign_key(app,foreign_table,_,_) then "foreign_text(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")", |
| 53 | integer_field(choices) then | 53 | integer_field(choices) then |
| 54 | if choices is | 54 | if choices is |
| 55 | { | 55 | { |
src/generation/web_args.anubis
| @@ -26,7 +26,7 @@ public define String | @@ -26,7 +26,7 @@ public define String | ||
| 26 | date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_date,", | 26 | date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_date,", |
| 27 | time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_time,", | 27 | time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_time,", |
| 28 | datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", | 28 | datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", |
| 29 | - foreign_key(_,_,_) then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", | 29 | + foreign_key(_,_,_,_) then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", |
| 30 | integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", | 30 | integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")", |
| 31 | float_field then "get_Float(lwa, __prefix__+\""+name+"\")", | 31 | float_field then "get_Float(lwa, __prefix__+\""+name+"\")", |
| 32 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", | 32 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", |
| @@ -81,7 +81,7 @@ public define String | @@ -81,7 +81,7 @@ public define String | ||
| 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,", | 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,", | 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,", | 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,", |
| 84 | - foreign_key(_,_,_) then "get_DB_id(lwa, __prefix__+\""+name+"\"),", | 84 | + foreign_key(_,_,_,_) then "get_DB_id(lwa, __prefix__+\""+name+"\"),", |
| 85 | integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", | 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)+"),", | 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)+"),", | 87 | char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),", |
| @@ -195,7 +195,7 @@ public define String | @@ -195,7 +195,7 @@ public define String | ||
| 195 | auto_now then "[field(\""+name+"\", bind_Datetime(\":v_"+name+"\", db_now))]", | 195 | auto_now then "[field(\""+name+"\", bind_Datetime(\":v_"+name+"\", db_now))]", |
| 196 | auto_now_add then "[]" | 196 | auto_now_add then "[]" |
| 197 | }, | 197 | }, |
| 198 | - foreign_key(_,_,_) then //"with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", | 198 | + foreign_key(_,_,_,_) then //"with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", |
| 199 | "if get_mb_DB_id(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_DB_id_or_NULL(\":v_"+name+"\", "+name+"))] }" | 199 | "if get_mb_DB_id(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_DB_id_or_NULL(\":v_"+name+"\", "+name+"))] }" |
| 200 | integer_field(_) then //"get_Int(lwa, __prefix__+\""+name+"\")", | 200 | integer_field(_) then //"get_Int(lwa, __prefix__+\""+name+"\")", |
| 201 | "if get_Int(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_Int(\":v_"+name+"\", "+name+"))] }" | 201 | "if get_Int(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_Int(\":v_"+name+"\", "+name+"))] }" |
src/model.3.0.0.anubis
| @@ -121,7 +121,7 @@ public define HK_Table production_production_table = | @@ -121,7 +121,7 @@ public define HK_Table production_production_table = | ||
| 121 | [ | 121 | [ |
| 122 | 122 | ||
| 123 | hk_column("date", date_field(none), []), | 123 | hk_column("date", date_field(none), []), |
| 124 | - hk_column("assembler_id", foreign_key(app_name("staff"),"staff", []), []), | 124 | + hk_column("assembler_id", foreign_key(app_name("staff"),"staff", [], []), []), |
| 125 | hk_column("type_ref_id", foreign_key("type_number"), []), | 125 | hk_column("type_ref_id", foreign_key("type_number"), []), |
| 126 | hk_column("product_ref_id", foreign_key("product_reference"), []), | 126 | hk_column("product_ref_id", foreign_key("product_reference"), []), |
| 127 | hk_column("site_id", foreign_key("production_site"), []), | 127 | hk_column("site_id", foreign_key("production_site"), []), |
| @@ -179,7 +179,7 @@ public define HK_Table production_purchase_table = | @@ -179,7 +179,7 @@ public define HK_Table production_purchase_table = | ||
| 179 | hk_model( | 179 | hk_model( |
| 180 | [ | 180 | [ |
| 181 | hk_column("date", date_field(none), []), | 181 | hk_column("date", date_field(none), []), |
| 182 | - hk_column("buyer_id", foreign_key(app_name("staff"),"staff", []), []), | 182 | + hk_column("buyer_id", foreign_key(app_name("staff"), "staff"), []), |
| 183 | hk_column("supplier_id", foreign_key("supplier"), []), | 183 | hk_column("supplier_id", foreign_key("supplier"), []), |
| 184 | hk_column("order_ref", char_field(50), []), // | 184 | hk_column("order_ref", char_field(50), []), // |
| 185 | hk_column("description", char_field(200), []), // description of the purchase | 185 | hk_column("description", char_field(200), []), // description of the purchase |
| @@ -246,7 +246,7 @@ public define HK_Table production_supplier_table = | @@ -246,7 +246,7 @@ public define HK_Table production_supplier_table = | ||
| 246 | [ | 246 | [ |
| 247 | 247 | ||
| 248 | hk_column("company", char_field(100), []), | 248 | hk_column("company", char_field(100), []), |
| 249 | - hk_column("contact_id", foreign_key(none, "address_book_contact", []), []), | 249 | + hk_column("contact_id", foreign_key(none, "address_book_contact"), []), |
| 250 | hk_column("address1", char_field(100), []), | 250 | hk_column("address1", char_field(100), []), |
| 251 | hk_column("address2", char_field(100), []), | 251 | hk_column("address2", char_field(100), []), |
| 252 | hk_column("zipcode", char_field(10), []), | 252 | hk_column("zipcode", char_field(10), []), |
| @@ -337,7 +337,7 @@ public define HK_Table staff_table = | @@ -337,7 +337,7 @@ public define HK_Table staff_table = | ||
| 337 | hk_model( | 337 | hk_model( |
| 338 | [ | 338 | [ |
| 339 | 339 | ||
| 340 | - hk_column("contact_id", foreign_key(none, "address_book_contact", []), []), | 340 | + hk_column("contact_id", foreign_key(none, "address_book_contact"), []), |
| 341 | hk_column("department_id", foreign_key("department"), []), | 341 | hk_column("department_id", foreign_key("department"), []), |
| 342 | hk_column("role_id", foreign_key("role"), []), | 342 | hk_column("role_id", foreign_key("role"), []), |
| 343 | hk_column("email", email_field, []), | 343 | hk_column("email", email_field, []), |