Mercurial > urweb
diff src/monoize.sml @ 261:ee51e9d35c9b
Monoize ORDER BY
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 31 Aug 2008 16:03:43 -0400 |
parents | 645d0e8da643 |
children | a6cb33f49366 |
line wrap: on
line diff
--- a/src/monoize.sml Sun Aug 31 15:47:32 2008 -0400 +++ b/src/monoize.sml Sun Aug 31 16:03:43 2008 -0400 @@ -555,7 +555,12 @@ (L'.TRecord [("Rows", s), ("OrderBy", s), ("Limit", s), ("Offset", s)], loc), s, strcat loc [gf "Rows", - gf "OrderBy", + (L'.ECase (gf "OrderBy", + [((L'.PPrim (Prim.String ""), loc), sc ""), + ((L'.PWild, loc), + strcat loc [sc " ORDER BY ", + gf "OrderBy"])], + {disc = s, result = s}), loc), gf "Limit", gf "Offset"]), loc), fm) end @@ -612,7 +617,11 @@ loc), s, strcat loc [sc "SELECT ", - strcatR loc (gf "SelectExps") sexps, + strcatComma loc (map (fn (x, t) => + strcat loc [ + (L'.EField (gf "SelectExps", x), loc), + sc (" AS _" ^ x) + ]) sexps), case sexps of [] => sc "" | _ => sc ", ", @@ -703,6 +712,30 @@ | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_order_by_Nil"), _), _), _), _) => ((L'.EPrim (Prim.String ""), loc), fm) + | L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.EFfi ("Basis", "sql_order_by_Cons"), _), + _), _), + _), _), + _) => + let + val s = (L'.TFfi ("Basis", "string"), loc) + fun sc s = (L'.EPrim (Prim.String s), loc) + in + ((L'.EAbs ("e1", s, (L'.TFun (s, s), loc), + (L'.EAbs ("e2", s, s, + (L'.ECase ((L'.ERel 0, loc), + [((L'.PPrim (Prim.String ""), loc), + (L'.ERel 1, loc)), + ((L'.PWild, loc), + strcat loc [(L'.ERel 1, loc), + sc ", ", + (L'.ERel 0, loc), + sc ")"])], + {disc = s, result = s}), loc)), loc)), loc), + fm) + end | L.EFfi ("Basis", "sql_no_limit") => ((L'.EPrim (Prim.String ""), loc), fm) @@ -800,6 +833,18 @@ (L.ECApp ( (L.ECApp ( (L.ECApp ( + (L.ECApp ( + (L.EFfi ("Basis", "sql_exp"), _), + _), _), + _), _), + _), _), + _), _), + (L.CName nm, _)) => ((L'.EPrim (Prim.String ("_" ^ nm)), loc), fm) + + | L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.ECApp ( (L.EFfi ("Basis", "sql_relop"), _), _), _), _), _),