summaryrefslogtreecommitdiff
path: root/tests/crud.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-14 19:14:40 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-14 19:14:40 -0400
commit1701925134c18b814afa186f76857f72cf388fc8 (patch)
tree2deff1a47b2cea1272930811f59097735bd47ece /tests/crud.ur
parentfe35c44cd34ceb2a2f02b27f56bf1607557bb89a (diff)
Crud completed
Diffstat (limited to 'tests/crud.ur')
-rw-r--r--tests/crud.ur14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/crud.ur b/tests/crud.ur
index 66a685bf..7944cf6c 100644
--- a/tests/crud.ur
+++ b/tests/crud.ur
@@ -27,7 +27,7 @@ fun create (inputs : $(mapT2T sndTT M.cols)) =
id <- nextval seq;
() <- dml (insert tab (foldT2R2 [sndTT] [colMeta]
[fn cols => $(mapT2T (fn t :: (Type * Type) =>
- sql_exp [T = [Id = int] ++ mapT2T fstTT M.cols] [] [] t.1) cols)]
+ sql_exp [] [] [] t.1) cols)]
(fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) =>
[[nm] ~ rest] =>
fn input col acc => acc with nm = sql_inject col.Inject (col.Parse input))
@@ -37,9 +37,17 @@ fun create (inputs : $(mapT2T sndTT M.cols)) =
Inserted with ID {txt _ id}.
</body></html>
-fun save (id : int) _ =
+fun save (id : int) (inputs : $(mapT2T sndTT M.cols)) =
+ () <- dml (update [mapT2T fstTT M.cols] (foldT2R2 [sndTT] [colMeta]
+ [fn cols => $(mapT2T (fn t :: (Type * Type) =>
+ sql_exp [T = [Id = int] ++ mapT2T fstTT M.cols] [] [] t.1) cols)]
+ (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) =>
+ [[nm] ~ rest] =>
+ fn input col acc => acc with nm = sql_inject col.Inject (col.Parse input))
+ {} [M.cols] inputs M.cols)
+ tab (WHERE T.Id = {id}));
return <html><body>
- Under Construction
+ Saved!
</body></html>
fun update (id : int) =