comparison demo/more/dbgrid.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 9253765d7724
children 818d4097e2ed
comparison
equal deleted inserted replaced
1774:27fdd78bd2f5 1775:6bc2a8cb3a67
383 val list = query (SELECT * FROM {{M.tab}} AS T) (fn r rs => return (r.T :: rs)) [] 383 val list = query (SELECT * FROM {{M.tab}} AS T) (fn r rs => return (r.T :: rs)) []
384 384
385 val wholeRow = @Folder.concat ! M.keyFolder M.rowFolder 385 val wholeRow = @Folder.concat ! M.keyFolder M.rowFolder
386 386
387 fun ensql [env] (r : $(M.key ++ M.row)) = 387 fun ensql [env] (r : $(M.key ++ M.row)) =
388 @map2 [rawMeta] [ident] [sql_exp env [] []] 388 @map2 [rawMeta] [ident] [sql_exp env [] [] disallow_window]
389 (fn [t] meta v => @sql_inject meta.Inj v) 389 (fn [t] meta v => @sql_inject meta.Inj v)
390 wholeRow M.raw r 390 wholeRow M.raw r
391 391
392 val new = 392 val new =
393 row <- @Monad.mapR _ [rawMeta] [ident] 393 row <- @Monad.mapR _ [rawMeta] [ident]
394 (fn [nm :: Name] [t :: Type] meta => meta.New) 394 (fn [nm :: Name] [t :: Type] meta => meta.New)
395 wholeRow M.raw; 395 wholeRow M.raw;
396 dml (insert M.tab (ensql row)); 396 dml (insert M.tab (ensql row));
397 return row 397 return row
398 398
399 fun selector (r : $M.key) : sql_exp [T = M.key ++ M.row] [] [] bool = 399 fun selector (r : $M.key) : sql_exp [T = M.key ++ M.row] [] [] disallow_window bool =
400 @foldR2 [rawMeta] [ident] 400 @foldR2 [rawMeta] [ident]
401 [fn key => rest :: {Type} -> [rest ~ key] => sql_exp [T = key ++ rest] [] [] bool] 401 [fn key => rest :: {Type} -> [rest ~ key] => sql_exp [T = key ++ rest] [] [] disallow_window bool]
402 (fn [nm :: Name] [t :: Type] [key :: {Type}] [[nm] ~ key] 402 (fn [nm :: Name] [t :: Type] [key :: {Type}] [[nm] ~ key]
403 (meta : rawMeta t) (v : t) 403 (meta : rawMeta t) (v : t)
404 (exp : rest :: {Type} -> [rest ~ key] => sql_exp [T = key ++ rest] [] [] bool) 404 (exp : rest :: {Type} -> [rest ~ key] => sql_exp [T = key ++ rest] [] [] disallow_window bool)
405 [rest :: {Type}] [rest ~ [nm = t] ++ key] => 405 [rest :: {Type}] [rest ~ [nm = t] ++ key] =>
406 (WHERE T.{nm} = {@sql_inject meta.Inj v} AND {exp [[nm = t] ++ rest]})) 406 (WHERE T.{nm} = {@sql_inject meta.Inj v} AND {exp [[nm = t] ++ rest]}))
407 (fn [rest :: {Type}] [rest ~ []] => (WHERE TRUE)) 407 (fn [rest :: {Type}] [rest ~ []] => (WHERE TRUE))
408 M.keyFolder (M.raw --- map rawMeta M.row) r 408 M.keyFolder (M.raw --- map rawMeta M.row) r
409 [_] ! 409 [_] !