comparison demo/crud.ur @ 1778:818d4097e2ed

Lighter-weight encoding of window function use
author Adam Chlipala <adam@chlipala.net>
date Sun, 03 Jun 2012 11:29:31 -0400
parents 6bc2a8cb3a67
children
comparison
equal deleted inserted replaced
1777:59b07fdae1ff 1778:818d4097e2ed
91 91
92 and create (inputs : $(map snd M.cols)) = 92 and create (inputs : $(map snd M.cols)) =
93 id <- nextval seq; 93 id <- nextval seq;
94 dml (insert tab 94 dml (insert tab
95 (@foldR2 [snd] [colMeta] 95 (@foldR2 [snd] [colMeta]
96 [fn cols => $(map (fn t => sql_exp [] [] [] disallow_window t.1) cols)] 96 [fn cols => $(map (fn t => sql_exp [] [] [] t.1) cols)]
97 (fn [nm :: Name] [t ::_] [rest ::_] [[nm] ~ rest] => 97 (fn [nm :: Name] [t ::_] [rest ::_] [[nm] ~ rest] =>
98 fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)}) 98 fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)})
99 {} M.fl inputs M.cols 99 {} M.fl inputs M.cols
100 ++ {Id = (SQL {[id]})})); 100 ++ {Id = (SQL {[id]})}));
101 ls <- list (); 101 ls <- list ();
108 and upd (id : int) = 108 and upd (id : int) =
109 let 109 let
110 fun save (inputs : $(map snd M.cols)) = 110 fun save (inputs : $(map snd M.cols)) =
111 dml (update [map fst M.cols] 111 dml (update [map fst M.cols]
112 (@foldR2 [snd] [colMeta] 112 (@foldR2 [snd] [colMeta]
113 [fn cols => $(map (fn t => sql_exp [T = [Id = int] ++ map fst M.cols] [] [] disallow_window t.1) cols)] 113 [fn cols => $(map (fn t => sql_exp [T = [Id = int] ++ map fst M.cols] [] [] t.1) cols)]
114 (fn [nm :: Name] [t ::_] [rest ::_] [[nm] ~ rest] => 114 (fn [nm :: Name] [t ::_] [rest ::_] [[nm] ~ rest] =>
115 fn input col acc => acc ++ {nm = 115 fn input col acc => acc ++ {nm =
116 @sql_inject col.Inject (col.Parse input)}) 116 @sql_inject col.Inject (col.Parse input)})
117 {} M.fl inputs M.cols) 117 {} M.fl inputs M.cols)
118 tab (WHERE T.Id = {[id]})); 118 tab (WHERE T.Id = {[id]}));