From fe35c44cd34ceb2a2f02b27f56bf1607557bb89a Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 14 Sep 2008 19:03:55 -0400 Subject: Crud update form --- lib/basis.urs | 2 +- lib/top.ur | 6 ++++++ lib/top.urs | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/basis.urs b/lib/basis.urs index ed217e3a..7fd5dc52 100644 --- a/lib/basis.urs +++ b/lib/basis.urs @@ -296,7 +296,7 @@ con lformTag = fn ty :: Type => fn inner :: {Unit} => fn attrs :: {Type} => ctx ::: {Unit} -> [LForm] ~ ctx -> nm :: Name -> unit -> tag attrs ([LForm] ++ ctx) inner [] [nm = ty] -val textbox : lformTag string [] [] +val textbox : lformTag string [] [Value = string] val password : lformTag string [] [] val ltextarea : lformTag string [] [] diff --git a/lib/top.ur b/lib/top.ur index 15f2a732..990a18fa 100644 --- a/lib/top.ur +++ b/lib/top.ur @@ -103,3 +103,9 @@ fun queryX (tables ::: {{Type}}) (exps ::: {Type}) (ctx ::: {Unit}) (q : sql_que query q (fn fs acc => return {acc}{f fs}) + +fun oneOrNoRows (tables ::: {{Type}}) (exps ::: {Type}) (q : sql_query tables exps) = + [tables ~ exps] => + query q + (fn fs _ => return (Some fs)) + None diff --git a/lib/top.urs b/lib/top.urs index 17ce5c28..add94578 100644 --- a/lib/top.urs +++ b/lib/top.urs @@ -66,3 +66,8 @@ val queryX : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} -> ($(exps ++ fold (fn nm (fields :: {Type}) acc => [nm] ~ acc => [nm = $fields] ++ acc) [] tables) -> xml ctx [] []) -> transaction (xml ctx [] []) + +val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type} -> sql_query tables exps + -> tables ~ exps + -> transaction + (option $(exps ++ fold (fn nm (fields :: {Type}) acc => [nm] ~ acc => [nm = $fields] ++ acc) [] tables)) -- cgit v1.2.3