# HG changeset patch # User Adam Chlipala # Date 1221351330 14400 # Node ID 18d5affa790df41951bad3497dc5b2a9f3b640b1 # Parent 34847732cefc0f6474ec249fa607515b372aaa61 Deletion for Crud diff -r 34847732cefc -r 18d5affa790d src/cjr_print.sml --- a/src/cjr_print.sml Sat Sep 13 20:04:28 2008 -0400 +++ b/src/cjr_print.sml Sat Sep 13 20:15:30 2008 -0400 @@ -898,7 +898,7 @@ end | EDml {dml, prepared} => - box [string "({", + box [string "(uw_begin_region(ctx), ({", newline, string "PGconn *conn = uw_get_db(ctx);", newline, @@ -970,9 +970,11 @@ string "PQclear(res);", newline, + string "uw_end_region(ctx);", + newline, string "uw_unit_v;", newline, - string "})"] + string "}))"] and p_exp env = p_exp' false env diff -r 34847732cefc -r 18d5affa790d tests/crud.ur --- a/tests/crud.ur Sat Sep 13 20:04:28 2008 -0400 +++ b/tests/crud.ur Sat Sep 13 20:15:30 2008 -0400 @@ -14,6 +14,18 @@ open constraints M val tab = M.tab +fun delete (id : int) = + () <- dml (DELETE FROM tab WHERE Id = {id}); + return + The deed is done. + + +fun confirm (id : int) = return +

Are you sure you want to delete ID #{txt _ id}?

+ +

I was born sure!

+ + fun main () : transaction page = rows <- queryX (SELECT * FROM tab AS T) (fn (fs : {T : $([Id = int] ++ M.cols)}) => @@ -26,6 +38,7 @@ {col.Show v} ) [M.cols] (fs.T -- #Id) M.cols} + [Delete] ); return