diff --git a/controller/hk_sql_utils.anubis b/controller/hk_sql_utils.anubis index 2e51511..3c39c89 100644 --- a/controller/hk_sql_utils.anubis +++ b/controller/hk_sql_utils.anubis @@ -435,14 +435,28 @@ public define List($T) ( SQLite3DataBase db, String table_name, - String id_col, String full_clause, (One -> SQLite3Row table_cursor) -> Maybe($T) extractor )= if sql_query_timeout(db, "SELECT * FROM "+table_name+" "+full_clause+";", [], "get_all_by_full_clause") is { - error(sql_error) then println("get_db_ids_by_full_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n id_col["+id_col+"]\nfull_clause ["+full_clause+";]");[], + error(sql_error) then println("get_all_by_full_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n full_clause ["+full_clause+";]");[], + ok(_, cursor, _) then _get_all(extractor)(cursor, []) + } +. + +public define List($T) + get_all_by_full_clause + ( + SQLite3DataBase db, + String full_clause, + (One -> SQLite3Row table_cursor) -> Maybe($T) extractor + )= + + if sql_query_timeout(db, full_clause+";", [], "get_all_by_full_clause") is + { + error(sql_error) then println("get_all_by_full_clause SQL ERROR '"+ sql_error.text + "'\n full_clause ["+full_clause+";]");[], ok(_, cursor, _) then _get_all(extractor)(cursor, []) } . @@ -655,10 +669,11 @@ public define Maybe(Int) { none then since make_insert_clause_and_binds(fields) is (binds, insert_columns, insert_values), - if sql_query_timeout(db, "INSERT INTO "+table_name+" "+insert_columns+" VALUES "+insert_values+";", binds, table_name+" (INSERT)") is + with insert_query = "INSERT INTO "+table_name+" "+insert_columns+" VALUES "+insert_values+";", + if sql_query_timeout(db, insert_query, binds, table_name+" (INSERT)") is { error(sql_error) then - //logError(debug_log, db_error(sql_error, table_name)); + println("insert on table '"+table_name+"' SQL ERROR '"+ sql_error.text + "'\n sql_insert ["+insert_query+"]\n binds "+dump_Binds(binds)); failure, ok(_, cursor, _) then if sql_query_scalar(db, "SELECT last_insert_rowid()") is @@ -676,9 +691,11 @@ public define Maybe(Int) }, db_id(idx) then since make_update_clause_and_binds(fields) is (binds, set_string), - if sql_query_timeout(db, "UPDATE "+table_name+" SET "+set_string +" WHERE id = "+idx+";", binds, table_name+" (UPDATE)") is + with update_query = "UPDATE "+table_name+" SET "+set_string +" WHERE id = "+idx+";", + if sql_query_timeout(db, update_query, binds, table_name+" (UPDATE)") is { error(sql_error) then + println("update on table '"+table_name+"' id ["+idx+"] SQL ERROR '"+ sql_error.text + "'\n sql_insert ["+update_query+"]\n binds "+dump_Binds(binds)); //logError(debug_log, db_error(sql_error, table_name)); failure, ok(_, _, _) then success(idx) -- libgit2 0.21.4