summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-10-20 13:08:42 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-10-20 13:08:42 -0400
commit3d97fb2839259bada8b730207d4b9de58659cfeb (patch)
treedd7bef7f7074492d4ff11411b7b87b14ebd532c0 /demo
parent8ba88fa1aacb63cff48fe42ba7d3dcfc31c45bbb (diff)
Saving changes to user list
Diffstat (limited to 'demo')
-rw-r--r--demo/more/bulkEdit.ur15
-rw-r--r--demo/more/bulkEdit.urs2
-rw-r--r--demo/more/conference.urp1
3 files changed, 18 insertions, 0 deletions
diff --git a/demo/more/bulkEdit.ur b/demo/more/bulkEdit.ur
index c033d2e8..004c77aa 100644
--- a/demo/more/bulkEdit.ur
+++ b/demo/more/bulkEdit.ur
@@ -4,6 +4,8 @@ functor Make(M : sig
con keyName :: Name
con keyType :: Type
val showKey : show keyType
+ val readKey : read keyType
+ val injKey : sql_injectable keyType
con visible :: {(Type * Type)}
constraint [keyName] ~ visible
@@ -21,6 +23,11 @@ functor Make(M : sig
open M
+ fun ensql [avail] (r : $(map snd visible)) : $(map (sql_exp avail [] []) (map fst visible)) =
+ map2 [meta] [snd] [fn ts :: (Type * Type) => sql_exp avail [] [] ts.1]
+ (fn [ts] meta v => @sql_inject meta.Inject (meta.Parse v))
+ [_] folder visible r
+
fun main () =
items <- queryX (SELECT t.{keyName}, t.{{map fst visible}} FROM t)
(fn r => <xml><entry><tr>
@@ -45,7 +52,15 @@ functor Make(M : sig
(fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] m =>
<xml><th>{[m.Nam]}</th></xml>) [_] folder visible}</tr>
<subforms{#Users}>{items}</subforms>
+ <tr> <td><submit value="Save" action={save}/></td> </tr>
</table></form>
</body></xml>
+ and save r =
+ List.app (fn user => dml (update [map fst visible] !
+ (ensql (user -- keyName))
+ t
+ (WHERE t.{keyName} = {[readError user.keyName]}))) r.Users;
+ main ()
+
end
diff --git a/demo/more/bulkEdit.urs b/demo/more/bulkEdit.urs
index 6593af1b..0e5d7a6c 100644
--- a/demo/more/bulkEdit.urs
+++ b/demo/more/bulkEdit.urs
@@ -2,6 +2,8 @@ functor Make(M : sig
con keyName :: Name
con keyType :: Type
val showKey : show keyType
+ val readKey : read keyType
+ val injKey : sql_injectable keyType
con visible :: {(Type * Type)}
constraint [keyName] ~ visible
diff --git a/demo/more/conference.urp b/demo/more/conference.urp
index 853b9b63..62ae39f9 100644
--- a/demo/more/conference.urp
+++ b/demo/more/conference.urp
@@ -1,5 +1,6 @@
$/option
+$/list
meta
bulkEdit
conference