Commit 059b51a694eb049f059c210dc35d03f6370c0c65
1 parent
24d83682
remove the generation of the function get_all_ +table_name and replace it by get…
…_all_ +"table_name"+ _by_clause.
Showing
4 changed files
with
35 additions
and
27 deletions
Show diff stats
calexium_lib @ 605449b023d
hayamiki_lib @ 7c694bdb28d
src/generation/types.anubis
| @@ -154,19 +154,19 @@ public define Maybe(One) | @@ -154,19 +154,19 @@ public define Maybe(One) | ||
| 154 | " failure then reverse(so_far),\n"+ | 154 | " failure then reverse(so_far),\n"+ |
| 155 | " success(data) then _get_all_"+name+"(table_cursor, [data . so_far])\n"+ | 155 | " success(data) then _get_all_"+name+"(table_cursor, [data . so_far])\n"+ |
| 156 | " }.\n"+ | 156 | " }.\n"+ |
| 157 | - "\n\n"+ | ||
| 158 | - //SQL query | ||
| 159 | - "public define List("+type_name+")\n"+ | ||
| 160 | - " get_all_"+name+"\n"+ | ||
| 161 | - " (\n"+ | ||
| 162 | - " SQLite3DataBase db,\n"+ | ||
| 163 | - " )=\n"+ | ||
| 164 | - " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ | ||
| 165 | - " {\n"+ | ||
| 166 | - " error(_) then [],\n"+ | ||
| 167 | - " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ | ||
| 168 | - " }.\n"+ | ||
| 169 | "\n\n" | 157 | "\n\n" |
| 158 | + //SQL query | ||
| 159 | +// "public define List("+type_name+")\n"+ | ||
| 160 | +// " get_all_"+name+"\n"+ | ||
| 161 | +// " (\n"+ | ||
| 162 | +// " SQLite3DataBase db,\n"+ | ||
| 163 | +// " )=\n"+ | ||
| 164 | +// " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+";\", [], \"get_all_"+name+"\") is\n"+ | ||
| 165 | +// " {\n"+ | ||
| 166 | +// " error(_) then [],\n"+ | ||
| 167 | +// " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ | ||
| 168 | +// " }.\n"+ | ||
| 169 | +// "\n\n" | ||
| 170 | ) is //end of the function | 170 | ) is //end of the function |
| 171 | { | 171 | { |
| 172 | failure then println("can't write generate_get_all "+type_name); failure, | 172 | failure then println("can't write generate_get_all "+type_name); failure, |
| @@ -192,7 +192,12 @@ public define Maybe(One) | @@ -192,7 +192,12 @@ public define Maybe(One) | ||
| 192 | " SQLite3DataBase db,\n"+ | 192 | " SQLite3DataBase db,\n"+ |
| 193 | " String clause\n"+ | 193 | " String clause\n"+ |
| 194 | " )=\n"+ | 194 | " )=\n"+ |
| 195 | - " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+" WHERE \"+clause+\";\", [], \"get_all_"+name+"_by_clause\") is\n"+ | 195 | + " with final_clause = if clause = \"\" then\n"+ |
| 196 | + " \"\"\n"+ | ||
| 197 | + " else\n"+ | ||
| 198 | + " \"WHERE \"+clause,\n"+ | ||
| 199 | + "\n"+ | ||
| 200 | + " if sql_query_timeout(db, \"SELECT "+join(", ", enclose("\\\"",to_List_String(columns, true)))+" FROM "+name+" \"+final_clause+\";\", [], \"get_all_"+name+"_by_clause\") is\n"+ | ||
| 196 | " {\n"+ | 201 | " {\n"+ |
| 197 | " error(_) then [],\n"+ | 202 | " error(_) then [],\n"+ |
| 198 | " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ | 203 | " ok(_, cursor, _) then _get_all_"+name+"(cursor, [])\n"+ |
| @@ -451,8 +456,9 @@ public define Maybe(One) | @@ -451,8 +456,9 @@ public define Maybe(One) | ||
| 451 | " get_selector_"+name+"\n"+ | 456 | " get_selector_"+name+"\n"+ |
| 452 | " (\n"+ | 457 | " (\n"+ |
| 453 | " SQLite3DataBase db,\n"+ | 458 | " SQLite3DataBase db,\n"+ |
| 459 | + " String clause\n"+ | ||
| 454 | " )=\n"+ | 460 | " )=\n"+ |
| 455 | - " _get_selector_"+name+"(db, get_all_"+name+"(db), [])." | 461 | + " _get_selector_"+name+"(db, get_all_"+name+"_by_clause(db, clause), [])." |
| 456 | ) is //end of the function | 462 | ) is //end of the function |
| 457 | { | 463 | { |
| 458 | failure then println("can't write generate_show_string "+type_name); failure, | 464 | failure then println("can't write generate_show_string "+type_name); failure, |
| @@ -513,9 +519,10 @@ public define Maybe(One) | @@ -513,9 +519,10 @@ public define Maybe(One) | ||
| 513 | "public define VT_view\n"+ | 519 | "public define VT_view\n"+ |
| 514 | " get_viewable_"+table_name+"_"+view_name+"\n"+ | 520 | " get_viewable_"+table_name+"_"+view_name+"\n"+ |
| 515 | " (\n"+ | 521 | " (\n"+ |
| 516 | - " SQLite3DataBase db\n"+ | 522 | + " SQLite3DataBase db,\n"+ |
| 523 | + " String clause\n"+ | ||
| 517 | " )=\n"+ | 524 | " )=\n"+ |
| 518 | - " _get_viewable_"+table_name+"_"+view_name+"(db, get_all_"+table_name+"(db), []).\n\n" | 525 | + " _get_viewable_"+table_name+"_"+view_name+"(db, get_all_"+table_name+"_by_clause(db, clause), []).\n\n" |
| 519 | ) is //end of the function | 526 | ) is //end of the function |
| 520 | { | 527 | { |
| 521 | failure then println("can't write generate_VT_view "+type_name); failure, | 528 | failure then println("can't write generate_VT_view "+type_name); failure, |
| @@ -575,7 +582,7 @@ public define String | @@ -575,7 +582,7 @@ public define String | ||
| 575 | [] then | 582 | [] then |
| 576 | so_far + | 583 | so_far + |
| 577 | "\n"+ | 584 | "\n"+ |
| 578 | - " _get_viewable_"+table_name+"_default(db, get_all_"+table_name+"(db), [])\n", | 585 | + " _get_viewable_"+table_name+"_default(db, get_all_"+table_name+"_by_clause(db, clause), [])\n", |
| 579 | [view . t] then | 586 | [view . t] then |
| 580 | with view_name = if view is | 587 | with view_name = if view is |
| 581 | { | 588 | { |
| @@ -585,7 +592,7 @@ public define String | @@ -585,7 +592,7 @@ public define String | ||
| 585 | _generate_get_viewable_if_else( table_name, t, | 592 | _generate_get_viewable_if_else( table_name, t, |
| 586 | so_far + | 593 | so_far + |
| 587 | " if view = \""+view_name+"\" then\n"+ | 594 | " if view = \""+view_name+"\" then\n"+ |
| 588 | - " _get_viewable_"+table_name+"_"+view_name+"(db, get_all_"+table_name+"(db), [])\n"+ | 595 | + " _get_viewable_"+table_name+"_"+view_name+"(db, get_all_"+table_name+"_by_clause(db, clause), [])\n"+ |
| 589 | " else" | 596 | " else" |
| 590 | ) | 597 | ) |
| 591 | }. | 598 | }. |
| @@ -606,7 +613,8 @@ public define Maybe(One) | @@ -606,7 +613,8 @@ public define Maybe(One) | ||
| 606 | " get_viewable_"+table_name+"\n"+ | 613 | " get_viewable_"+table_name+"\n"+ |
| 607 | " (\n"+ | 614 | " (\n"+ |
| 608 | " SQLite3DataBase db,\n"+ | 615 | " SQLite3DataBase db,\n"+ |
| 609 | - " String view\n"+ | 616 | + " String view,\n"+ |
| 617 | + " String clause\n"+ | ||
| 610 | " )=\n"+ | 618 | " )=\n"+ |
| 611 | _generate_get_viewable_if_else(table_name, list_view, "")+ | 619 | _generate_get_viewable_if_else(table_name, list_view, "")+ |
| 612 | ".\n" | 620 | ".\n" |
src/generation/vt_edit.anubis
| @@ -23,8 +23,8 @@ define String | @@ -23,8 +23,8 @@ define String | ||
| 23 | join(",\n", | 23 | join(",\n", |
| 24 | map((HK_FK_View fk_view) | 24 | map((HK_FK_View fk_view) |
| 25 | |-> | 25 | |-> |
| 26 | - since fk_view is fk_view(app_name, table_name, fk_col), | ||
| 27 | - indent+"hk_v_edit_tab(String fk_table_name, "+fk_col+", \"default\")" | 26 | + since fk_view is fk_view(app_name, fk_table_name, fk_col), |
| 27 | + indent+" hk_v_edit_tab(\""+fk_table_name+"\", \""+fk_col+"\", \"default\")" | ||
| 28 | , | 28 | , |
| 29 | fk_views) | 29 | fk_views) |
| 30 | ) | 30 | ) |
| @@ -47,16 +47,16 @@ public define Maybe(One) | @@ -47,16 +47,16 @@ public define Maybe(One) | ||
| 47 | with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. | 47 | with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type. |
| 48 | with view_name = if edit_view is | 48 | with view_name = if edit_view is |
| 49 | { | 49 | { |
| 50 | - edit_view_all then "default", | ||
| 51 | - edit_view(view_name, _, _) then view_name | 50 | + edit_view_all then "default", |
| 51 | + edit_view(v_name, _, _) then v_name | ||
| 52 | }, | 52 | }, |
| 53 | with current_edit_view = if edit_view is | 53 | with current_edit_view = if edit_view is |
| 54 | { | 54 | { |
| 55 | edit_view_all then columns, | 55 | edit_view_all then columns, |
| 56 | - edit_view(view_name, cols, _) then | 56 | + edit_view(v_name, cols, _) then |
| 57 | if get_HK_Model_Column_list_from_name_list(columns, cols) is | 57 | if get_HK_Model_Column_list_from_name_list(columns, cols) is |
| 58 | { | 58 | { |
| 59 | - failure then println("generate_VT_edit: can't get all specified columns for table \""+table_name+"\" view name \""+view_name+"\" cols["+join(", ",cols)+"]");[], | 59 | + failure then println("generate_VT_edit: can't get all specified columns for table \""+table_name+"\" view name \""+v_name+"\" cols["+join(", ",cols)+"]");[], |
| 60 | success(got_columns) then got_columns, | 60 | success(got_columns) then got_columns, |
| 61 | } | 61 | } |
| 62 | }, | 62 | }, |