diff --git a/ds_files/graphviz.gv b/ds_files/graphviz.gv
index 3b94813..8e83808 100644
--- a/ds_files/graphviz.gv
+++ b/ds_files/graphviz.gv
@@ -1,8 +1,8 @@
/*
* Created by 伝作 (Densaku).
* Types & Messages generator written by フランスのトトロ aka (David RENÉ)
- * Date: 2018-11-10
- * Time: 17:14:38
+ * Date: 2019-07-14
+ * Time: 16:15:41
*
*/
@@ -159,6 +159,7 @@ digraph DS {
| HK_App_Name | app_name |
| String | table_name |
| List(String) | searchable_fields |
+ | List(HK_Foreign_Key_Active_Filter) | hk_fk_active_filter |
| List(HK_Foreign_Key_Clause) | hk_fk_clause |
| ) |
@@ -199,6 +200,7 @@ digraph DS {
HK_Model_Field:char_field_choices -> HK_Text_Choices:TYPE
HK_Model_Field:integer_field_choices -> HK_Int_Choices:TYPE
HK_Model_Field:foreign_key_app_name -> HK_App_Name:TYPE
+ HK_Model_Field:foreign_key_hk_fk_active_filter -> HK_Foreign_Key_Active_Filter:TYPE
HK_Model_Field:foreign_key_hk_fk_clause -> HK_Foreign_Key_Clause:TYPE
HK_Model_Field:datetime_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE
HK_Model_Field:time_field_hk_dt_f_attr -> HK_Datetime_Field_Attr:TYPE
@@ -256,6 +258,20 @@ digraph DS {
HK_Foreign_Key_Clause:on_delete_on_delete -> HK_Foreign_Key_Clause_On_Directive:TYPE
+ HK_Foreign_Key_Active_Filter [ label=<
+
+ | HK_Foreign_Key_Active_Filter |
+
+ | active_filter ( |
+ | String | column |
+ | String | fk_column |
+ | ) |
+
+
+ >];
+
+
+
HK_Int_Choices [ label=<
| HK_Int_Choices |
diff --git a/hayamiki_ds_types.aproj b/hayamiki_ds_types.aproj
index 0508f38..70b176e 100644
--- a/hayamiki_ds_types.aproj
+++ b/hayamiki_ds_types.aproj
@@ -26,6 +26,9 @@
+
+
+
@@ -39,29 +42,47 @@
+
-
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -72,5 +93,6 @@
+
\ No newline at end of file
diff --git a/hayamiki_generator.aproj b/hayamiki_generator.aproj
index 21bacb3..5e1731d 100644
--- a/hayamiki_generator.aproj
+++ b/hayamiki_generator.aproj
@@ -147,6 +147,7 @@
+
@@ -163,9 +164,11 @@
+
+
@@ -524,6 +527,7 @@
+
diff --git a/hayamiki_lib b/hayamiki_lib
index 6b95d3a..c6bd97b 160000
--- a/hayamiki_lib
+++ b/hayamiki_lib
@@ -1 +1 @@
-Subproject commit 6b95d3a55ad17f9e884442211234e56ffd9735b6
+Subproject commit c6bd97b105cf57b04fe2daf4482ba45e119c7b5d
diff --git a/src/check.anubis b/src/check.anubis
index 3c607ac..552460e 100644
--- a/src/check.anubis
+++ b/src/check.anubis
@@ -42,7 +42,7 @@ define Maybe(HK_Model_Column)
HK_Model_Column col
)=
since col is hk_column(name, type, attrib, help),
- if type is foreign_key(fk_app, fk_table, fields, fk_clause) then
+ if type is foreign_key(fk_app, fk_table, fields, active_filter, fk_clause) then
//TODO check for searchable fields if exists in foreign table
with mb_fk_app = if (fk_app) is
{
@@ -59,7 +59,7 @@ define Maybe(HK_Model_Column)
if mb_fk_app is
{
failure then failure,
- 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))
+ 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, active_filter, fk_clause), attrib, help))
}
else
success(col).
diff --git a/src/generation/columns.anubis b/src/generation/columns.anubis
index ccce439..411128e 100644
--- a/src/generation/columns.anubis
+++ b/src/generation/columns.anubis
@@ -156,7 +156,7 @@ public define Maybe(String)
auto_now_add then
if insert then success(name) else failure
},
- foreign_key(_,_,_,_) then success(name),
+ foreign_key(_,_,_,_,_) then success(name),
integer_field(_) then success(name),
float_field then success(name),
char_field(_,_) then success(name),
@@ -251,12 +251,12 @@ public define Maybe(String)
auto_now then success("information(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+".datetime, 18, "+to_Anubis_source(help)+")"),
auto_now_add then success("information(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+".datetime, 18, "+to_Anubis_source(help)+")")
},
- foreign_key(app,foreign_table,fields,_) then
+ foreign_key(app,foreign_table,fields,active_filters,_) then
if length(fields) = 0 then
- 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)+")")
+ 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(active_filters)+", "+to_Anubis_source(help)+")")
else
with search_fields = join(", ", map((String field) |-> "\""+field+"\"",fields)),
- success("foreign_text_search(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", \""+foreign_table+"\", ["+search_fields+"], "+to_Anubis_source(help)+")"),
+ success("foreign_text_search(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", \""+foreign_table+"\", ["+search_fields+"], "+to_Anubis_source(active_filters)+", "+to_Anubis_source(help)+")"),
integer_field(choices) then
//success("integer(\""+to_upper(name)+"\", \""+name+"\", "+type_name+"."+name+", "+to_Anubis_source(help)+")"),
@@ -334,7 +334,7 @@ public define String
date_field(attrs) then "to_String("+current_type_name+"."+name+")",
time_field(attrs) then "to_String("+current_type_name+"."+name+")",
datetime_field(attrs) then "to_String("+current_type_name+"."+name+")"
- foreign_key(app,foreign_table,_,_) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")",
+ foreign_key(app,foreign_table,_,_,_) then "get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+")",
integer_field(_) then "to_String("+current_type_name+"."+name+")",
float_field then "float_to_string("+current_type_name+"."+name+",5)",
char_field(_,_) then current_type_name+"."+name,
diff --git a/src/generation/extractor.anubis b/src/generation/extractor.anubis
index 79d366a..ccb7974 100644
--- a/src/generation/extractor.anubis
+++ b/src/generation/extractor.anubis
@@ -25,7 +25,7 @@ public define String
date_field(_) then "db_date(text"+cursor_index+")",
time_field(_) then "db_time(text"+cursor_index+")",
datetime_field(_) then "db_datetime(text"+cursor_index+")",
- foreign_key(_,_,_,_) then "db_id((Int)db_integer"+cursor_index+")",
+ foreign_key(_,_,_,_,_) then "db_id((Int)db_integer"+cursor_index+")",
integer_field(_) then "(Int)db_integer"+cursor_index,
float_field then "db_float"+cursor_index,
char_field(_,_) then "text"+cursor_index,
diff --git a/src/generation/fields.anubis b/src/generation/fields.anubis
index df1cc94..ceef3a8 100644
--- a/src/generation/fields.anubis
+++ b/src/generation/fields.anubis
@@ -30,7 +30,7 @@ public define String
date_field(_) then "DB_date",
time_field(_) then "DB_time",
datetime_field(_) then "DB_datetime",
- foreign_key(_,_,_,_) then "DB_id",
+ foreign_key(_,_,_,_,_) then "DB_id",
integer_field(_) then "Int",
float_field then "Float",
char_field(_,_) then "String",
@@ -56,7 +56,7 @@ public define String
date_field(_) then "extern_type(\"DB_date\", \"calexium_lib/database/db_types.anubis\")",
time_field(_) then "extern_type(\"DB_time\", \"calexium_lib/database/db_types.anubis\")",
datetime_field(_) then "extern_type(\"DB_datetime\", \"calexium_lib/database/db_types.anubis\")",
- foreign_key(_,_,_,_) then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")",
+ foreign_key(_,_,_,_,_) then "extern_type(\"DB_id\", \"calexium_lib/database/db_types.anubis\")",
integer_field(_) then "int",
float_field then "float",
char_field(_,_) then "string",
@@ -89,7 +89,7 @@ public define String
datetime_field(dt_attrs) then
with new_attributes = if dt_attrs is auto_now_add then [default("(datetime('now', 'LOCALTIME'))")] else attributes,
fill("DATETIME", 15) + format_attributes(new_attributes),
- foreign_key(app,fk,_,fk_clause) then fill("INTEGER", 15) + format_attributes(attributes)+" REFERENCES "+fk+"(id) "+format_fk_clause(fk_clause),
+ foreign_key(app,fk,_,_,fk_clause) then fill("INTEGER", 15) + format_attributes(attributes)+" REFERENCES "+fk+"(id) "+format_fk_clause(fk_clause),
integer_field(_) then fill("INTEGER", 15) + format_attributes(attributes),
float_field then fill("DOUBLE", 15) + format_attributes(attributes),
char_field(_,size) then fill("VARCHAR("+size+")", 15) + format_attributes(attributes),
@@ -116,7 +116,7 @@ public define String
date_field(_) then "db_date(\"\")",
time_field(_) then "db_time(\"\")",
datetime_field(_) then "db_datetime(\"\")",
- foreign_key(_,_,_,_) then "(DB_id)none",
+ foreign_key(_,_,_,_,_) then "(DB_id)none",
integer_field(_) then "(Int)0",
float_field then "(Float)0.0",
char_field(choices,size) then "\"\"",
@@ -161,7 +161,7 @@ public define String
else
""
},
- foreign_key(_,_,_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")",
+ foreign_key(_,_,_,_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")",
integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")",
float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")",
char_field(_,_) then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
diff --git a/src/generation/header.anubis b/src/generation/header.anubis
index 836147f..e5c2474 100644
--- a/src/generation/header.anubis
+++ b/src/generation/header.anubis
@@ -22,7 +22,7 @@ define Maybe(One)
[] then success(unique),
[h . t] then
since h is hk_column(_, type, _, _),
- if type is foreign_key(app, table_name, _, _) then
+ if type is foreign_key(app, table_name, _, _, _) then
if write_string(stream, "\nread database/generated/"+table_name+".anubis") is
{
failure then failure,
diff --git a/src/generation/html.anubis b/src/generation/html.anubis
index c4833a9..267e1f1 100644
--- a/src/generation/html.anubis
+++ b/src/generation/html.anubis
@@ -98,7 +98,7 @@ public define String
date_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
time_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
datetime_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
- foreign_key(app, foreign_table,_,_) then to_HTML_cell_text(column, data_name, general_type_name),
+ foreign_key(app, foreign_table,_,_,_) then to_HTML_cell_text(column, data_name, general_type_name),
integer_field(choices) then to_HTML_cell_text(column, data_name, general_type_name),
float_field then to_HTML_cell_text(column, data_name, general_type_name),
char_field(choices, size) then to_HTML_cell_text(column, data_name, general_type_name),
diff --git a/src/generation/icons.anubis b/src/generation/icons.anubis
index 8817bd9..8274546 100644
--- a/src/generation/icons.anubis
+++ b/src/generation/icons.anubis
@@ -28,7 +28,7 @@ public define String
date_field(attrs) then icn16_clock,
time_field(attrs) then icn16_clock,
datetime_field(attrs) then icn16_clock,
- foreign_key(app,foreign_table,_,_) then icn16_question,
+ foreign_key(app,foreign_table,_,_,_) then icn16_question,
integer_field(choice) then icn16_question,
float_field then icn16_question,
char_field(choice, size) then icn16_question,
diff --git a/src/generation/json.anubis b/src/generation/json.anubis
index 0e89d21..d8906fd 100644
--- a/src/generation/json.anubis
+++ b/src/generation/json.anubis
@@ -28,7 +28,7 @@ public define String
date_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))",
time_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))",
datetime_field(attrs) then "to_JSON_String(to_String("+current_type_name+"."+name+"))",
- foreign_key(app,foreign_table,_,_) then "to_JSON_String(get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+"))",
+ foreign_key(app,foreign_table,_,_,_) then "to_JSON_String(get_"+foreign_table+"_show_string(db, "+current_type_name+"."+name+"))",
integer_field(_) then current_type_name+"."+name,
float_field then "float_to_string("+current_type_name+"."+name+",5)",
char_field(_,_) then "to_JSON_String("+current_type_name+"."+name+")",
@@ -62,7 +62,7 @@ public define String
date_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
time_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
datetime_field(attrs) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
- 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+")",
+ 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+")",
integer_field(_) then "json_member(\""+name+"\", json_int("+current_type_name+"."+name+"))",
float_field then "json_member(\""+name+"\", json_float("+current_type_name+"."+name+",5))",
char_field(_,_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
@@ -92,7 +92,7 @@ public define String
date_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
time_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
datetime_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
- foreign_key(app,foreign_table,_,_) then
+ foreign_key(app,foreign_table,_,_,_) then
" if resolve_fk then\n"+
" json_member(\""+name+"\", json_string(get_"+foreign_table+"_show_string(db, db_id((Int)db_integer"+cursor_index+"))))\n"+
" else\n"+
diff --git a/src/generation/vt_view.anubis b/src/generation/vt_view.anubis
index 83ff91e..50a92d6 100644
--- a/src/generation/vt_view.anubis
+++ b/src/generation/vt_view.anubis
@@ -49,7 +49,7 @@ define String
date_field(attrs) then "date(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
time_field(attrs) then "time(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
datetime_field(attrs) then "datetime(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
- foreign_key(app,foreign_table,_,_) then "foreign_text(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")",
+ foreign_key(app,foreign_table,_,active_filters,_) then "foreign_text(\""+to_upper(name)+"\", \""+name+"\", hk_form_selector(get_selector_"+foreign_table+"), "+to_Anubis_source(help)+")",
integer_field(choices) then
if choices is
{
diff --git a/src/generation/web_args.anubis b/src/generation/web_args.anubis
index 05574c2..3256211 100644
--- a/src/generation/web_args.anubis
+++ b/src/generation/web_args.anubis
@@ -26,7 +26,7 @@ public define String
date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_date,",
time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_time,",
datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,",
- foreign_key(_,_,_,_) then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),",
+ foreign_key(_,_,_,_,_) then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),",
integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\")",
float_field then "get_Float(lwa, __prefix__+\""+name+"\")",
char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")",
@@ -81,7 +81,7 @@ public define String
date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," else "get_dummy_DB_date,",
time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," else "get_dummy_DB_time,",
datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+")," else "get_dummy_DB_datetime,",
- foreign_key(_,_,_,_) then "get_DB_id(lwa, __prefix__+\""+name+"\"),",
+ foreign_key(_,_,_,_,_) then "get_DB_id(lwa, __prefix__+\""+name+"\"),",
integer_field(_) then "get_Int(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
float_field then "get_Float(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
@@ -195,7 +195,7 @@ public define String
auto_now then "[field(\""+name+"\", bind_Datetime(\":v_"+name+"\", db_now))]",
auto_now_add then "[]"
},
- foreign_key(_,_,_,_) then //"with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),",
+ foreign_key(_,_,_,_,_) then //"with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),",
"if get_mb_DB_id(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_DB_id_or_NULL(\":v_"+name+"\", "+name+"))] }"
integer_field(_) then //"get_Int(lwa, __prefix__+\""+name+"\")",
"if get_Int(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_Int(\":v_"+name+"\", "+name+"))] }"
diff --git a/src/main.anubis b/src/main.anubis
index b40b3ff..a30e0cc 100644
--- a/src/main.anubis
+++ b/src/main.anubis
@@ -3,7 +3,7 @@
*
* *Title* Interfacing, generating and controling a database with Anubis
*
- * *Copyright* Copyright © David René 2015-2017.
+ * *Copyright* Copyright © David René 2015-2019.
*
*
*
diff --git a/src/model.3.0.0.anubis b/src/model.3.0.0.anubis
index 2f29ffd..b9ab53c 100644
--- a/src/model.3.0.0.anubis
+++ b/src/model.3.0.0.anubis
@@ -121,7 +121,7 @@ public define HK_Table production_production_table =
[
hk_column("date", date_field(none), []),
- hk_column("assembler_id", foreign_key(app_name("staff"),"staff", [], []), []),
+ hk_column("assembler_id", foreign_key(app_name("staff"),"staff"), []),
hk_column("type_ref_id", foreign_key("type_number"), []),
hk_column("product_ref_id", foreign_key("product_reference"), []),
hk_column("site_id", foreign_key("production_site"), []),
--
libgit2 0.21.4