Commit 25d77d406d6cc4ca858443ad88ffd824747c807b

Authored by David RENÉ
2 parents 4d0c7352 8d022f53

Merge branch '1.19' of ssh://gitlab.anubis-lang.com:33000/totoro/hayamiki_lib into 1.19

Showing 1 changed file with 36 additions and 9 deletions   Show diff stats
controller/hk_sql_utils.anubis
@@ -38,15 +38,19 @@ public define Maybe(One) @@ -38,15 +38,19 @@ public define Maybe(One)
38 String table_name, 38 String table_name,
39 List(Int) ids 39 List(Int) ids
40 )= 40 )=
41 - if sql_query_timeout(db,  
42 - "DELETE FROM "+table_name+  
43 - " WHERE id IN ("+join(", ", to_List_String(ids))+");",  
44 - [],  
45 - "delete_from_ids") is  
46 - {  
47 - error(_) then failure,  
48 - ok(_, _, _) then success(unique)  
49 - }. 41 + if length(ids) = 0 then
  42 + success(unique)
  43 + else
  44 + if sql_query_timeout(db,
  45 + "DELETE FROM "+table_name+
  46 + " WHERE id IN ("+join(", ", to_List_String(ids))+");",
  47 + [],
  48 + "delete_from_ids") is
  49 + {
  50 + error(_) then failure,
  51 + ok(_, _, _) then success(unique)
  52 + }
  53 + .
50 54
51 public define Maybe(One) 55 public define Maybe(One)
52 delete_by_clause 56 delete_by_clause
@@ -101,6 +105,29 @@ public define Int @@ -101,6 +105,29 @@ public define Int
101 db_get_Int(db, clause, []) 105 db_get_Int(db, clause, [])
102 . 106 .
103 107
  108 +public define List(String)
  109 + db_get_List_String
  110 + (
  111 + SQLite3DataBase db,
  112 + String clause,
  113 + List(SQLite3Bind) binds
  114 + )=
  115 + if sql_query_timeout(db, clause+";", binds, "db_get_List_String") is
  116 + {
  117 + error(sql_error) then println("db_get_List_String SQL ERROR '"+ sql_error.text + "'\n clause ["+clause+";]");[],
  118 + ok(_, cursor, _) then db_get_List_String(cursor)
  119 + }
  120 +.
  121 +
  122 +public define List(String)
  123 + db_get_List_String
  124 + (
  125 + SQLite3DataBase db,
  126 + String clause
  127 + )=
  128 + db_get_List_String(db, clause, [])
  129 +.
  130 +
104 public define Float 131 public define Float
105 get_count_float_by_full_clause 132 get_count_float_by_full_clause
106 ( 133 (