Commit 53075ced7a6faa784f08a4bd38bc46ed76f92c1e
1 parent
0dc1ce02
add label and column name in primary_key alternative. This allows to see and edi…
…t the DB_id other than the first "id" update the fs_file database
Showing
6 changed files
with
31 additions
and
19 deletions
Show diff stats
hayamiki_lib @ d169d6079aa
src/generation/vt_view.anubis
| ... | ... | @@ -44,7 +44,7 @@ define String |
| 44 | 44 | since col is hk_column(name, col_type, _, help), |
| 45 | 45 | if col_type is |
| 46 | 46 | { |
| 47 | - p_key then "primary_key", | |
| 47 | + p_key then "primary_key(\""+to_upper(name)+"\", \""+name+"\")", | |
| 48 | 48 | boolean_field then "boolean(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", |
| 49 | 49 | date_field(attrs) then "date(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", |
| 50 | 50 | time_field(attrs) then "time(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")", | ... | ... |
src/web_controller/database/generated/fs_file.anubis
| 1 | 1 | /* |
| 2 | 2 | * Created by 早見木 (Hayamiki). |
| 3 | 3 | * Database generator written by フランスのトトロ aka (David RENÉ) |
| 4 | - * Date: 2020-04-11 | |
| 5 | - * Time: 10:13:41 | |
| 4 | + * Date: 2022-10-23 | |
| 5 | + * Time: 17:24:03 | |
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | transmit tools/basis.anubis |
| ... | ... | @@ -135,6 +135,7 @@ public define List(SQLite3_update_field) |
| 135 | 135 | List(Web_arg) lwa, |
| 136 | 136 | String __prefix__ |
| 137 | 137 | )= |
| 138 | + (List(SQLite3_update_field)) | |
| 138 | 139 | []+ |
| 139 | 140 | []+ |
| 140 | 141 | [field("write_date", bind_Datetime(":v_write_date", db_now))]+ |
| ... | ... | @@ -165,7 +166,7 @@ public define Maybe(Fs_file) |
| 165 | 166 | row(cursor) then |
| 166 | 167 | success( |
| 167 | 168 | fs_file( |
| 168 | - db_id((Int)db_integer(cursor)(0)) /* id */, | |
| 169 | + db_id_or_null(cursor)(0) /* id */, | |
| 169 | 170 | db_datetime(text(cursor)(1)) /* create_date */, |
| 170 | 171 | db_datetime(text(cursor)(2)) /* write_date */, |
| 171 | 172 | text(cursor)(3) /* res_model */, |
| ... | ... | @@ -427,9 +428,14 @@ public define Maybe(Int) |
| 427 | 428 | }, |
| 428 | 429 | db_id(idx) then |
| 429 | 430 | if sql_query_timeout(db, |
| 430 | - "UPDATE fs_file SET | |
| 431 | + "INSERT INTO fs_file | |
| 432 | + (\"id\", \"create_date\", \"write_date\", \"res_model\", \"res_name\", \"file_size\", \"res_id\", \"description\", \"res_field\", \"mimetype\", \"name\", \"url\", \"checksum\", \"datas_fname\", \"path\") | |
| 433 | + VALUES | |
| 434 | + (:v_id, :v_create_date, :v_write_date, :v_res_model, :v_res_name, :v_file_size, :v_res_id, :v_description, :v_res_field, :v_mimetype, :v_name, :v_url, :v_checksum, :v_datas_fname, :v_path) | |
| 435 | + ON CONFLICT( \"id\") DO UPDATE SET | |
| 431 | 436 | \"write_date\" = :v_write_date, \"res_model\" = :v_res_model, \"res_name\" = :v_res_name, \"file_size\" = :v_file_size, \"res_id\" = :v_res_id, \"description\" = :v_description, \"res_field\" = :v_res_field, \"mimetype\" = :v_mimetype, \"name\" = :v_name, \"url\" = :v_url, \"checksum\" = :v_checksum, \"datas_fname\" = :v_datas_fname, \"path\" = :v_path |
| 432 | - WHERE id = "+idx+";", | |
| 437 | + WHERE id = :v_id;", | |
| 438 | + [bind_Int(":v_id", idx)]+ | |
| 433 | 439 | [ |
| 434 | 440 | bind_Datetime(":v_write_date", db_now), |
| 435 | 441 | bind_String_or_NULL(":v_res_model", fs_file.res_model), |
| ... | ... | @@ -458,7 +464,7 @@ public define Maybe(Int) |
| 458 | 464 | )= |
| 459 | 465 | if extract_Fs_file_from_web_arg(lwa, "") is |
| 460 | 466 | { |
| 461 | - failure then logError("update_fs_file extract_Fs_file_from_web_arg is failure"); failure, | |
| 467 | + failure then logError("update_fs_file extract_Fs_file_from_web_arg is failure"); failure, | |
| 462 | 468 | success(fs_file) then update_fs_file(db, fs_file) |
| 463 | 469 | }. |
| 464 | 470 | |
| ... | ... | @@ -488,7 +494,17 @@ public define String |
| 488 | 494 | failure then default_select, |
| 489 | 495 | success(obj) then obj.name |
| 490 | 496 | } |
| 491 | - }. | |
| 497 | + } | |
| 498 | +. | |
| 499 | + | |
| 500 | +public define String | |
| 501 | + get_fs_file_show_string | |
| 502 | + ( | |
| 503 | + SQLite3DataBase db, | |
| 504 | + Fs_file obj | |
| 505 | + )= | |
| 506 | + obj.name | |
| 507 | +. | |
| 492 | 508 | |
| 493 | 509 | define List((List(CoreAttrs), WebArgValue, String)) |
| 494 | 510 | _get_selector_fs_file |
| ... | ... | @@ -501,11 +517,7 @@ define List((List(CoreAttrs), WebArgValue, String)) |
| 501 | 517 | { |
| 502 | 518 | [] then [selector_default_entry . reverse(so_far)], |
| 503 | 519 | [ h . t ] then |
| 504 | - if h.id is | |
| 505 | - { | |
| 506 | - none then [selector_default_entry], | |
| 507 | - db_id(_id) then _get_selector_fs_file(db, t, [([], wav(to_String(_id)), get_fs_file_show_string(db, h.id)) . so_far]) | |
| 508 | - } | |
| 520 | + _get_selector_fs_file(db, t, [([], wav(to_String(h.id)), get_fs_file_show_string(db, h)) . so_far]) | |
| 509 | 521 | }. |
| 510 | 522 | |
| 511 | 523 | public define List((List(CoreAttrs), WebArgValue, String)) |
| ... | ... | @@ -552,7 +564,7 @@ define VT_view |
| 552 | 564 | text("PATH") |
| 553 | 565 | ]), |
| 554 | 566 | with model = vt_view_model([ |
| 555 | - primary_key, | |
| 567 | + primary_key("ID", "id"), | |
| 556 | 568 | datetime("CREATE_DATE", "create_date", no_help_text), |
| 557 | 569 | datetime("WRITE_DATE", "write_date", no_help_text), |
| 558 | 570 | text("RES_MODEL", "res_model", no_help_text), | ... | ... |
src/web_controller/hkc_files_management.anubis
| ... | ... | @@ -64,7 +64,7 @@ public define (WEB_Session) -> WEB_Controller_Result |
| 64 | 64 | set_file(db, "hkc", hkc_file_id, filename, "file", filename, "hkc/"+to_fs_folder(hkc_file_id)); |
| 65 | 65 | ajax(json(http_ok, json_object([json_member("uploaded", json_int(1)), |
| 66 | 66 | json_member("fileName", json_string(filename)), |
| 67 | - json_member("url", json_string("?aws_controller=hk_c&aws_action=download&file="+hkc_file_id))]))) | |
| 67 | + json_member("url", json_string("?aws_c=hk_c&aws_a=download&file="+hkc_file_id))]))) | |
| 68 | 68 | else |
| 69 | 69 | println("move_file error from ["+temp_filepath+"] to ["+final_filename+"]"); |
| 70 | 70 | ajax(json(http_ok, json_object([json_member("uploaded", json_int(0)), | ... | ... |
src/web_controller/types/generated/fs_file.anubis