diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-08-31 16:20:34 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-08-31 16:20:34 -0400 |
commit | e63d9fdd9bc5c0316f3467fa762e27f5e482ed75 (patch) | |
tree | df3d873a9858c1d1e36fb8cea7d5d1b58c04772b /src | |
parent | 9a3af2ced0937e9578595053f730cb1b11cca6e5 (diff) |
Monoize COUNT(*)
Diffstat (limited to 'src')
-rw-r--r-- | src/monoize.sml | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/monoize.sml b/src/monoize.sml index 920291a6..df606085 100644 --- a/src/monoize.sml +++ b/src/monoize.sml @@ -423,8 +423,9 @@ fun strcatComma loc es = val es = List.take (es, length es - 1) in foldr (fn (e, e') => - case e of - (L'.EPrim (Prim.String ""), _) => e' + case (e, e') of + ((L'.EPrim (Prim.String ""), _), _) => e' + | (_, (L'.EPrim (Prim.String ""), _)) => e | _ => (L'.EStrcat (e, (L'.EStrcat ((L'.EPrim (Prim.String ", "), loc), e'), loc)), loc)) @@ -621,15 +622,12 @@ fun monoExp (env, st, fm) (all as (e, loc)) = strcat loc [ (L'.EField (gf "SelectExps", x), loc), sc (" AS _" ^ x) - ]) sexps), - case sexps of - [] => sc "" - | _ => sc ", ", - strcatComma loc (map (fn (x, xts) => - strcatComma loc - (map (fn (x', _) => - sc (x ^ "." ^ x')) - xts)) stables), + ]) sexps + @ map (fn (x, xts) => + strcatComma loc + (map (fn (x', _) => + sc (x ^ "." ^ x')) + xts)) stables), sc " FROM ", strcatComma loc (map (fn (x, _) => strcat loc [(L'.EField (gf "From", x), loc), sc (" AS " ^ x)]) tables), @@ -918,6 +916,16 @@ fun monoExp (env, st, fm) (all as (e, loc)) = | L.EFfi ("Basis", "sql_intersect") => ((L'.EPrim (Prim.String "INTERSECT"), loc), fm) | L.EFfi ("Basis", "sql_except") => ((L'.EPrim (Prim.String "EXCEPT"), loc), fm) + | L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.EFfi ("Basis", "sql_count"), _), + _), _), + _), _), + _) => ((L'.EAbs ("_", (L'.TRecord [], loc), (L'.TFfi ("Basis", "string"), loc), + (L'.EPrim (Prim.String "COUNT(*)"), loc)), loc), + fm) + | L.EApp ( (L.ECApp ( (L.ECApp ((L.EFfi ("Basis", "cdata"), _), _), _), |