diff --git a/calexium_lib/database/db_utils.anubis b/calexium_lib/database/db_utils.anubis index 3c102c7..44558e2 100644 --- a/calexium_lib/database/db_utils.anubis +++ b/calexium_lib/database/db_utils.anubis @@ -89,6 +89,28 @@ public define DbQueryResult ok(headers, cursor, reset) }. + public define DbQueryResult + sql_query_timeout + ( + Database db, //database handle + String sql_query, //sql query itself + String msg //message to be shown if an error occure + ) = + sql_query_timeout(db, sql_query, [], msg). + +public define Maybe(One -> DbRow) + sql_query_timeout + ( + Database db, //database handle + String sql_query, //sql query itself + String msg //message to be shown if an error occure + ) = + if sql_query_timeout(db, sql_query, [], msg) is + { + error(_) then failure, + ok(_,cursor,_) then success(cursor) + }. + // deprecated. Use one of the previous ones. public define SQLite3QueryResult sql_query_timeout @@ -110,6 +132,15 @@ public define SQLite3QueryResult ok(headers, cursor, reset) }. +public define SQLite3QueryResult + sql_query_timeout + ( + SQLite3DataBase db, //database handle + String sql_query, //sql query itself + String msg //message to be shown if an error occure + ) = + sql_query_timeout(db, sql_query, [], msg). + // -- Extractors HELPERS --------------- public define List(String) diff --git a/calexium_lib/database/settings.anubis b/calexium_lib/database/settings.anubis index 5b8a4f9..c1f4738 100644 --- a/calexium_lib/database/settings.anubis +++ b/calexium_lib/database/settings.anubis @@ -15,13 +15,13 @@ public define Maybe(String) select_settings ( Database db, - String var, + String var, )= if sql_query_timeout(db, "SELECT var_value FROM settings WHERE var_name=" + db_make_sql_string(var) + ";", "select_settings") is { failure then failure, //error in the SQL request success(table_cursor) then - if table_cursor(next_row) is + if table_cursor(unique) is { error(_) then failure, no_more_row then failure, //can't find the var_value in the table, because the row is empty -- libgit2 0.21.4