diff src/sql.sml @ 2209:0ca11d57c175

Cleans up interface (it's now a command line option) and renames project to "sqlcache" in the all-one-word style. Still has issues to do with concurrency, retrying transactions, and foreign function calls that either rely on state or have side effects.
author Ziv Scully <ziv@mit.edu>
date Sat, 31 May 2014 03:08:16 -0400
parents 01c8aceac480
children ef766ef6e242
line wrap: on
line diff
--- a/src/sql.sml	Fri May 30 12:00:44 2014 -0400
+++ b/src/sql.sml	Sat May 31 03:08:16 2014 -0400
@@ -177,10 +177,10 @@
                                     else
                                         NONE)
 
-val field = wrap (follow t_ident
-                         (follow (const ".")
-                                 uw_ident))
-                 (fn (t, ((), f)) => (t, f))
+val field = wrap (follow (opt (follow t_ident (const ".")))
+                         uw_ident)
+                 (fn (SOME (t, ()), f) => (t, f)
+                   | (NONE, f) => ("T", f)) (* Should probably deal with this MySQL/SQLite case better some day. *)
 
 datatype Rel =
          Exps of exp * exp -> prop
@@ -396,22 +396,22 @@
 val delete = log "delete"
                  (wrap (follow (const "DELETE FROM ")
                                (follow uw_ident
-                                       (follow (const " AS T_T WHERE ")
+                                       (follow (follow (opt (const " AS T_T")) (const " WHERE "))
                                                sqexp)))
-                       (fn ((), (tab, ((), es))) => (tab, es)))
+                       (fn ((), (tab, (_, es))) => (tab, es)))
 
 val setting = log "setting"
-              (wrap (follow uw_ident (follow (const " = ") sqexp))
-               (fn (f, ((), e)) => (f, e)))
+                  (wrap (follow uw_ident (follow (const " = ") sqexp))
+                        (fn (f, ((), e)) => (f, e)))
 
 val update = log "update"
                  (wrap (follow (const "UPDATE ")
                                (follow uw_ident
-                                       (follow (const " AS T_T SET ")
+                                       (follow (follow (opt (const " AS T_T")) (const " SET "))
                                                (follow (list setting)
                                                        (follow (ws (const "WHERE "))
                                                                sqexp)))))
-                       (fn ((), (tab, ((), (fs, ((), e))))) =>
+                       (fn ((), (tab, (_, (fs, ((), e))))) =>
                            (tab, fs, e)))
 
 val dml = log "dml"