comparison demo/crud.ur @ 1775:6bc2a8cb3a67

Track whether SQL expressions may use window functions, in preparation for actual window function support
author Adam Chlipala <adam@chlipala.net>
date Sat, 02 Jun 2012 15:35:58 -0400
parents c7b9a33c26c8
children 818d4097e2ed
comparison
equal deleted inserted replaced
1774:27fdd78bd2f5 1775:6bc2a8cb3a67
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 [] [] [] t.1) cols)] 96 [fn cols => $(map (fn t => sql_exp [] [] [] disallow_window 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] [] [] t.1) cols)] 113 [fn cols => $(map (fn t => sql_exp [T = [Id = int] ++ map fst M.cols] [] [] disallow_window 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]}));