Commit be77f1b0ed80d55a220c7c9f5563d08fc3a70652
Merge branch 'master' of ssh://gitlab.calexium.com:33022/calexium/hayamiki
Showing
2 changed files
with
19 additions
and
17 deletions
Show diff stats
src/generation/fields.anubis
| ... | ... | @@ -83,16 +83,16 @@ public define String |
| 83 | 83 | if t is |
| 84 | 84 | { |
| 85 | 85 | //anubis(_T) then "constant_byte_array(0,0)", |
| 86 | - p_key then "with "+name+" = get_DB_id(lwa, \""+name+"\"),", | |
| 86 | + p_key then "with "+name+" = get_DB_id(lwa, __prefix__+\""+name+"\"),", | |
| 87 | 87 | //binary then "constant_byte_array(0,0)", |
| 88 | - boolean_field then "with "+name+" = get_Bool(lwa, \""+name+"\"),", | |
| 89 | - date_field(attrs) then if attrs = none then "get_DB_date(lwa, \""+name+"\")" else "with "+name+" = get_dummy_DB_date,", | |
| 90 | - time_field(attrs) then if attrs = none then "get_DB_time(lwa, \""+name+"\")" else "with "+name+" = get_dummy_DB_time,", | |
| 91 | - datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, \""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", | |
| 92 | - foreign_key(_,_) then "get_Int(lwa, \""+name+"\")", | |
| 93 | - integer_field then "get_Int(lwa, \""+name+"\")", | |
| 94 | - char_field(_,_) then "get_String(lwa, \""+name+"\")", | |
| 95 | - text_field then "get_String(lwa, \""+name+"\")" | |
| 88 | + boolean_field then "with "+name+" = get_Bool(lwa, __prefix__+\""+name+"\"),", | |
| 89 | + date_field(attrs) then if attrs = none then "get_DB_date(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_date,", | |
| 90 | + time_field(attrs) then if attrs = none then "get_DB_time(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_time,", | |
| 91 | + datetime_field(attrs) then if attrs = none then "get_DB_datetime(lwa, __prefix__+\""+name+"\")" else "with "+name+" = get_dummy_DB_datetime,", | |
| 92 | + foreign_key(_,_) then "get_Int(lwa, __prefix__+\""+name+"\")", | |
| 93 | + integer_field then "get_Int(lwa, __prefix__+\""+name+"\")", | |
| 94 | + char_field(_,_) then "get_String(lwa, __prefix__+\""+name+"\")", | |
| 95 | + text_field then "get_String(lwa, __prefix__+\""+name+"\")" | |
| 96 | 96 | }. |
| 97 | 97 | |
| 98 | 98 | public define String | ... | ... |
src/generation/types.anubis
| ... | ... | @@ -123,18 +123,18 @@ public define Maybe(One) |
| 123 | 123 | since _generate_extract_web_arg(columns, [], 0) is ((List(String))list_of_web_arg, (Int) nb_closure), |
| 124 | 124 | //generate the type of the table that contain all components |
| 125 | 125 | if write_string(stream, |
| 126 | - "\n\ndefine Maybe("+type_name+")\n"+ | |
| 127 | - " extract_from_web_arg\n"+ | |
| 126 | + "\n\npublic define Maybe("+type_name+")\n"+ | |
| 127 | + " extract_"+type_name+"_from_web_arg\n"+ | |
| 128 | 128 | " (\n"+ |
| 129 | 129 | " List(Web_arg) lwa,\n"+ |
| 130 | - " String prefix\n"+ | |
| 130 | + " String __prefix__\n"+ | |
| 131 | 131 | " )=\n"+ //head of the definition |
| 132 | 132 | to_String(list_of_web_arg)+ //all editable components of the type |
| 133 | 133 | " success(\n"+generate_constructor(name, columns, " ")+")\n"+ //generate type construction with values got from web arg |
| 134 | 134 | " "+fill(nb_closure, '}')+ //add close } according to number of web arg |
| 135 | 135 | ".\n") is //end of the function |
| 136 | 136 | { |
| 137 | - failure then println("can't write extract_from_web_arg "+type_name); failure, | |
| 137 | + failure then println("can't write extract_"+type_name+"_from_web_arg "+type_name); failure, | |
| 138 | 138 | success(_) then success(unique) |
| 139 | 139 | }. |
| 140 | 140 | |
| ... | ... | @@ -283,12 +283,14 @@ public define Maybe(One) |
| 283 | 283 | " \"update_"+name+" (INSERT)\")),\n"+ |
| 284 | 284 | //UPDATE SQL query |
| 285 | 285 | " db_id(idx) then\n"+ |
| 286 | - " forget(sql_query_timeout(db,\n"+ | |
| 286 | + " if sql_query_timeout(db,\n"+ | |
| 287 | 287 | " \"UPDATE "+name+" SET\n"+ |
| 288 | 288 | update_values(columns, " ")+"\n"+ |
| 289 | 289 | " WHERE id = \"+idx+\";\",\n"+ |
| 290 | 290 | generate_Bind_list(columns, name, " ", false)+",\n"+ |
| 291 | - " \"update_"+name+" (UPDATE)\"))\n"+ | |
| 291 | + " \"update_"+name+" (UPDATE)\") is { \n"+ | |
| 292 | + " error(sql_error)\n"+ | |
| 293 | + " then logError(debug_log, db_error(sql_error, \"update_"+name+"\")), ok(_, _, _) then unique }\n"+ | |
| 292 | 294 | " }.\n\n"+ |
| 293 | 295 | "public define Maybe(One)\n"+ |
| 294 | 296 | " update_"+name+"\n"+ |
| ... | ... | @@ -296,9 +298,9 @@ public define Maybe(One) |
| 296 | 298 | " SQLite3DataBase db,\n"+ |
| 297 | 299 | " List(Web_arg) lwa\n"+ |
| 298 | 300 | " )=\n"+ |
| 299 | - " if extract_from_web_arg(lwa, \"\") is\n"+ | |
| 301 | + " if extract_"+type_name+"_from_web_arg(lwa, \"\") is\n"+ | |
| 300 | 302 | " {\n"+ |
| 301 | - " failure then failure,\n"+ | |
| 303 | + " failure then logError(debug_log, \"update_"+name+" extract_"+type_name+"_from_web_arg is failure\"); failure,\n"+ | |
| 302 | 304 | " success("+name+") then success(update_"+name+"(db, "+name+"))\n"+ |
| 303 | 305 | " }.\n\n" |
| 304 | 306 | ... | ... |