Mercurial > urweb
changeset 305:55eedecb6c50
Remove need to mention table name in expressions for UPDATE and DELETE
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 07 Sep 2008 14:30:32 -0400 |
parents | 148ba06f3e67 |
children | 99e4f39e820d |
files | lib/basis.urs src/urweb.grm tests/delete.ur tests/update.ur |
diffstat | 4 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/basis.urs Sun Sep 07 14:19:05 2008 -0400 +++ b/lib/basis.urs Sun Sep 07 14:30:32 2008 -0400 @@ -206,19 +206,19 @@ val insert : fields ::: {Type} -> sql_table fields -> $(fold (fn nm (t :: Type) acc => [nm] ~ acc => - [nm = sql_exp [T = fields] [] [] t] ++ acc) [] fields) + [nm = sql_exp [] [] [] t] ++ acc) [] fields) -> dml -val update : changed ::: {Type} -> unchanged ::: {Type} -> changed ~ unchanged +val update : changed :: {Type} -> unchanged ::: {Type} -> changed ~ unchanged + -> sql_table (changed ++ unchanged) -> $(fold (fn nm (t :: Type) acc => [nm] ~ acc => - [nm = sql_exp [T = changed ++ unchanged] [] [] t] ++ acc) [] changed) - -> sql_table (changed ++ unchanged) - -> sql_exp [T = changed ++ unchanged] [] [] bool + [nm = sql_exp [] [] (changed ++ unchanged) t] ++ acc) [] changed) + -> sql_exp [] [] (changed ++ unchanged) bool -> dml val delete : fields ::: {Type} -> sql_table fields - -> sql_exp [T = fields] [] [] bool + -> sql_exp [] [] fields bool -> dml
--- a/src/urweb.grm Sun Sep 07 14:19:05 2008 -0400 +++ b/src/urweb.grm Sun Sep 07 14:30:32 2008 -0400 @@ -753,8 +753,12 @@ val loc = s (LPARENleft, RPARENright) val e = (EVar (["Basis"], "update"), loc) + val e = (ECApp (e, (CRecord (map (fn (nm, _) => + (nm, + (CWild (KType, loc), loc))) + fsets), loc)), loc) + val e = (EApp (e, texp), loc) val e = (EApp (e, (ERecord fsets, loc)), loc) - val e = (EApp (e, texp), loc) in (EApp (e, sqlexp), loc) end)
--- a/tests/delete.ur Sun Sep 07 14:19:05 2008 -0400 +++ b/tests/delete.ur Sun Sep 07 14:30:32 2008 -0400 @@ -1,5 +1,5 @@ table t1 : {A : int, B : string, C : float, D : bool} fun main () : transaction page = - () <- dml (DELETE FROM t1 WHERE T.A = 5); + () <- dml (DELETE FROM t1 WHERE A = 5); return <html><body>Deleted.</body></html>
--- a/tests/update.ur Sun Sep 07 14:19:05 2008 -0400 +++ b/tests/update.ur Sun Sep 07 14:30:32 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 = '6', C = 7.0 WHERE A = 5); return <html><body>Updated.</body></html>