Commit be9ff1bdb7c63bb179e183487593ddfd6a331820
1 parent
d169d607
[~] don't delete anything if no id provided
Showing
1 changed file
with
13 additions
and
9 deletions
Show diff stats
controller/hk_sql_utils.anubis
| ... | ... | @@ -38,15 +38,19 @@ public define Maybe(One) |
| 38 | 38 | String table_name, |
| 39 | 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 | 55 | public define Maybe(One) |
| 52 | 56 | delete_by_clause | ... | ... |