diff options
author | Adam Chlipala <adam@chlipala.net> | 2018-03-13 15:30:11 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2018-03-13 15:30:11 -0400 |
commit | de2d8358dda08bfaf491d815df91d0c1ba33e7c9 (patch) | |
tree | f819be05586e191199befbcbf87b5743e3cdcc9c /src/monoize.sml | |
parent | e2d548c69e2a83ace5123ade21262aa27336fb6b (diff) |
Handle empty SELECT clauses
Diffstat (limited to 'src/monoize.sml')
-rw-r--r-- | src/monoize.sml | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/monoize.sml b/src/monoize.sml index 60ff78ea..85a66e87 100644 --- a/src/monoize.sml +++ b/src/monoize.sml @@ -1792,18 +1792,21 @@ fun monoExp (env, st, fm) (all as (e, loc)) = NONE), loc), str "")], {disc = b, result = s}), loc), - strcatComma (map (fn (x, t) => - strcat [ - (L'.EField (gf "SelectExps", x), loc), - str (" AS " ^ Settings.mangleSql x) - ]) sexps - @ map (fn (x, xts) => - strcatComma - (map (fn (x', _) => - str ("T_" ^ x - ^ "." - ^ Settings.mangleSql x')) - xts)) stables), + if List.null sexps andalso List.all (List.null o #2) stables then + str "0" + else + strcatComma (map (fn (x, t) => + strcat [ + (L'.EField (gf "SelectExps", x), loc), + str (" AS " ^ Settings.mangleSql x) + ]) sexps + @ map (fn (x, xts) => + strcatComma + (map (fn (x', _) => + str ("T_" ^ x + ^ "." + ^ Settings.mangleSql x')) + xts)) stables), (L'.ECase (gf "From", [((L'.PPrim (Prim.String (Prim.Normal, "")), loc), str ""), |