From 1701925134c18b814afa186f76857f72cf388fc8 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 14 Sep 2008 19:14:40 -0400 Subject: Crud completed --- tests/crud.ur | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/crud.ur') 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}. -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 - Under Construction + Saved! fun update (id : int) = -- cgit v1.2.3