# HG changeset patch # User Adam Chlipala # Date 1220814767 14400 # Node ID 72480e249130896347d09809d62f62b0ce4f1285 # Parent 52d4c60518d46ff9acee92ca55d3b15c7c4b9e85 First UPDATE works diff -r 52d4c60518d4 -r 72480e249130 src/monoize.sml --- a/src/monoize.sml Sun Sep 07 15:05:52 2008 -0400 +++ b/src/monoize.sml Sun Sep 07 15:12:47 2008 -0400 @@ -600,6 +600,7 @@ (L'.EDml (liftExpInExp 0 e), loc)), loc), fm) end + | L.ECApp ((L.EFfi ("Basis", "insert"), _), fields) => (case monoType env (L.TRecord fields, loc) of (L'.TRecord fields, _) => @@ -624,6 +625,35 @@ end | _ => poly ()) + | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "update"), _), changed), _), _) => + (case monoType env (L.TRecord changed, loc) of + (L'.TRecord changed, _) => + let + val s = (L'.TFfi ("Basis", "string"), loc) + val changed = map (fn (x, _) => (x, s)) changed + val rt = (L'.TRecord changed, loc) + fun sc s = (L'.EPrim (Prim.String s), loc) + in + ((L'.EAbs ("fs", rt, (L'.TFun (s, (L'.TFun (s, s), loc)), loc), + (L'.EAbs ("tab", s, (L'.TFun (s, s), loc), + (L'.EAbs ("e", s, s, + strcat loc [sc "UPDATE ", + (L'.ERel 1, loc), + sc " AS T SET ", + strcatComma loc (map (fn (x, _) => + strcat loc [sc ("lw_" ^ x + ^ " = "), + (L'.EField + ((L'.ERel 2, + loc), + x), loc)]) + changed), + sc " WHERE ", + (L'.ERel 0, loc)]), loc)), loc)), loc), + fm) + end + | _ => poly ()) + | L.ECApp ( (L.ECApp ( (L.ECApp ((L.EFfi ("Basis", "query"), _), (L.CRecord (_, tables), _)), _), diff -r 52d4c60518d4 -r 72480e249130 tests/update.ur --- a/tests/update.ur Sun Sep 07 15:05:52 2008 -0400 +++ b/tests/update.ur Sun Sep 07 15:12:47 2008 -0400 @@ -1,5 +1,5 @@ table t1 : {A : int, B : string, C : float, D : bool} fun main () : transaction page = - () <- dml (UPDATE t1 SET B = '6', C = 7.0 WHERE T.A = 5); + () <- dml (UPDATE t1 SET B = 'Hi', C = 12.34 WHERE T.A = 5); return Updated.