diff --git a/controller/hk_sql_utils.anubis b/controller/hk_sql_utils.anubis index 929b68e..a3cc7ca 100644 --- a/controller/hk_sql_utils.anubis +++ b/controller/hk_sql_utils.anubis @@ -105,7 +105,7 @@ public define Int if sql_query_timeout(db, "SELECT COUNT(\""+table_name+".id\") FROM "+table_name+" "+clause+";", [], "get_count_by_clause") is { - error(_) then 0, + error(sql_error) then println("get_count_by_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n clause ["+clause+";]");0, ok(_, cursor, _) then db_get_Int(cursor) } . @@ -135,7 +135,7 @@ public define List(Int) if sql_query_timeout(db, "SELECT \"id\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is { - error(_) then [], + error(sql_error) then println("get_ids_by_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n clause ["+clause+";]");[], ok(_, cursor, _) then db_get_List_Int(cursor) } . @@ -152,9 +152,9 @@ public define List(DB_id) else "WHERE "+clause, - if sql_query_timeout(db, "SELECT \"id\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is + if sql_query_timeout(db, "SELECT \"id\" FROM "+table_name+" "+final_clause+";", [], "get_db_ids_by_clause") is { - error(_) then [], + error(sql_error) then println("get_db_ids_by_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n clause ["+clause+";]");[], ok(_, cursor, _) then db_get_List_DB_id(cursor) } . @@ -174,7 +174,7 @@ public define List(Int) if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is { - error(_) then [], + error(sql_error) then println("get_ids_by_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n id_col["+id_col+"]\nclause ["+clause+";]");[], ok(_, cursor, _) then db_get_List_Int(cursor) } . @@ -194,7 +194,23 @@ public define List(DB_id) if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is { - error(_) then [], + error(sql_error) then println("get_db_ids_by_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n id_col["+id_col+"]\nclause ["+clause+";]");[], + ok(_, cursor, _) then db_get_List_DB_id(cursor) + } +. + +public define List(DB_id) + get_db_ids_by_full_clause + ( + SQLite3DataBase db, + String table_name, + String id_col, + String full_clause + )= + + if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+full_clause+";", [], "get_db_ids_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+";]");[], ok(_, cursor, _) then db_get_List_DB_id(cursor) } . @@ -356,6 +372,23 @@ public define (One -> SQLite3Row table_cursor) -> List($T) real_get(cursor, []) . +public define List($T) + get_all_by_full_clause + ( + 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+";]");[], + ok(_, cursor, _) then _get_all(extractor)(cursor, []) + } +. + public define (String, String, String, String) -> List($T) call_back_get_all_by_clause ( -- libgit2 0.21.4