comparison demo/crud.ur @ 471:20fab0e96217

Tree demo working (and other assorted regressions fixed)
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Nov 2008 19:43:48 -0500
parents d4a81273d4b1
children 12d163bb856f
comparison
equal deleted inserted replaced
470:7cb418e9714f 471:20fab0e96217
100 sql_exp [] [] [] t.1) cols)] 100 sql_exp [] [] [] t.1) cols)]
101 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) 101 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
102 [[nm] ~ rest] => 102 [[nm] ~ rest] =>
103 fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)}) 103 fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)})
104 {} [M.cols] inputs M.cols 104 {} [M.cols] inputs M.cols
105 ++ {Id = (SQL {id})})); 105 ++ {Id = (SQL {[id]})}));
106 ls <- list (); 106 ls <- list ();
107 return <xml><body> 107 return <xml><body>
108 <p>Inserted with ID {[id]}.</p> 108 <p>Inserted with ID {[id]}.</p>
109 109
110 {ls} 110 {ls}
120 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) 120 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
121 [[nm] ~ rest] => 121 [[nm] ~ rest] =>
122 fn input col acc => acc ++ {nm = 122 fn input col acc => acc ++ {nm =
123 @sql_inject col.Inject (col.Parse input)}) 123 @sql_inject col.Inject (col.Parse input)})
124 {} [M.cols] inputs M.cols) 124 {} [M.cols] inputs M.cols)
125 tab (WHERE T.Id = {id})); 125 tab (WHERE T.Id = {[id]}));
126 ls <- list (); 126 ls <- list ();
127 return <xml><body> 127 return <xml><body>
128 <p>Saved!</p> 128 <p>Saved!</p>
129 129
130 {ls} 130 {ls}
131 </body></xml> 131 </body></xml>
132 132
133 and upd (id : int) = 133 and upd (id : int) =
134 fso <- oneOrNoRows (SELECT tab.{{mapT2T fstTT M.cols}} FROM tab WHERE tab.Id = {id}); 134 fso <- oneOrNoRows (SELECT tab.{{mapT2T fstTT M.cols}} FROM tab WHERE tab.Id = {[id]});
135 case fso : (Basis.option {Tab : $(mapT2T fstTT M.cols)}) of 135 case fso : (Basis.option {Tab : $(mapT2T fstTT M.cols)}) of
136 None => return <xml><body>Not found!</body></xml> 136 None => return <xml><body>Not found!</body></xml>
137 | Some fs => return <xml><body><form> 137 | Some fs => return <xml><body><form>
138 {foldT2R2 [fstTT] [colMeta] [fn cols :: {(Type * Type)} => xml form [] (mapT2T sndTT cols)] 138 {foldT2R2 [fstTT] [colMeta] [fn cols :: {(Type * Type)} => xml form [] (mapT2T sndTT cols)]
139 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) 139 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
148 148
149 <submit action={save id}/> 149 <submit action={save id}/>
150 </form></body></xml> 150 </form></body></xml>
151 151
152 and delete (id : int) = 152 and delete (id : int) =
153 dml (DELETE FROM tab WHERE Id = {id}); 153 dml (DELETE FROM tab WHERE Id = {[id]});
154 ls <- list (); 154 ls <- list ();
155 return <xml><body> 155 return <xml><body>
156 <p>The deed is done.</p> 156 <p>The deed is done.</p>
157 157
158 {ls} 158 {ls}