summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-07 14:30:32 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-07 14:30:32 -0400
commitdf8eea45a9ba38963b5bcc58b4e6439c055524e4 (patch)
tree8a352989a67720ba4146c04fe75dc4503d023e45
parenta8bc278b2a46d93bec4bf88cd7e56f12a253f061 (diff)
Remove need to mention table name in expressions for UPDATE and DELETE
-rw-r--r--lib/basis.urs12
-rw-r--r--src/urweb.grm6
-rw-r--r--tests/delete.ur2
-rw-r--r--tests/update.ur2
4 files changed, 13 insertions, 9 deletions
diff --git a/lib/basis.urs b/lib/basis.urs
index a095a57e..91933254 100644
--- a/lib/basis.urs
+++ b/lib/basis.urs
@@ -206,19 +206,19 @@ val dml : dml -> transaction unit
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
- -> $(fold (fn nm (t :: Type) acc => [nm] ~ acc =>
- [nm = sql_exp [T = changed ++ unchanged] [] [] t] ++ acc) [] changed)
+val update : changed :: {Type} -> unchanged ::: {Type} -> changed ~ unchanged
-> sql_table (changed ++ unchanged)
- -> sql_exp [T = changed ++ unchanged] [] [] bool
+ -> $(fold (fn nm (t :: Type) acc => [nm] ~ acc =>
+ [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
diff --git a/src/urweb.grm b/src/urweb.grm
index 61e8d179..ef267b37 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -753,8 +753,12 @@ eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
val loc = s (LPARENleft, RPARENright)
val e = (EVar (["Basis"], "update"), loc)
- val e = (EApp (e, (ERecord fsets, loc)), 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)
in
(EApp (e, sqlexp), loc)
end)
diff --git a/tests/delete.ur b/tests/delete.ur
index e2109f61..fee63812 100644
--- a/tests/delete.ur
+++ b/tests/delete.ur
@@ -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>
diff --git a/tests/update.ur b/tests/update.ur
index e58c10cb..06de35f8 100644
--- a/tests/update.ur
+++ b/tests/update.ur
@@ -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>