changeset 1081:25d491287358

Basis.sql_nullable and Top.queryL
author Adam Chlipala <adamc@hcoop.net>
date Tue, 22 Dec 2009 12:13:23 -0500
parents a4979e31e4bf
children 4b2f50829af5
files lib/ur/basis.urs lib/ur/top.ur lib/ur/top.urs src/monoize.sml
diffstat 4 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/basis.urs	Sun Dec 20 15:17:43 2009 -0500
+++ b/lib/ur/basis.urs	Tue Dec 22 12:13:23 2009 -0500
@@ -484,6 +484,11 @@
 val sql_octet_length : sql_ufunc blob int
 
 
+val sql_nullable : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} -> t ::: Type
+                   -> sql_injectable_prim t
+                   -> sql_exp tables agg exps t
+                   -> sql_exp tables agg exps (option t)
+
 (*** Executing queries *)
 
 val query : tables ::: {{Type}} -> exps ::: {Type}
--- a/lib/ur/top.ur	Sun Dec 20 15:17:43 2009 -0500
+++ b/lib/ur/top.ur	Tue Dec 22 12:13:23 2009 -0500
@@ -208,6 +208,11 @@
                <xml>{f [nm] [t] [rest] ! r1 r2 r3}{acc}</xml>)
            <xml/>
 
+fun queryL [tables] [exps] [tables ~ exps] (q : sql_query tables exps) =
+    query q
+    (fn r ls => return (r :: ls))
+    []
+
 fun queryI [tables ::: {{Type}}] [exps ::: {Type}]
            [tables ~ exps] (q : sql_query tables exps)
            (f : $(exps ++ map (fn fields :: {Type} => $fields) tables)
--- a/lib/ur/top.urs	Sun Dec 20 15:17:43 2009 -0500
+++ b/lib/ur/top.urs	Tue Dec 22 12:13:23 2009 -0500
@@ -118,6 +118,11 @@
               -> r :: {K} -> folder r
               -> $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> xml ctx [] []
 
+val queryL : tables ::: {{Type}} -> exps ::: {Type}
+             -> [tables ~ exps] =>
+                  sql_query tables exps
+                  -> transaction (list $(exps ++ map (fn fields :: {Type} => $fields) tables))
+
 val queryI : tables ::: {{Type}} -> exps ::: {Type}
              -> [tables ~ exps] =>
              sql_query tables exps
--- a/src/monoize.sml	Sun Dec 20 15:17:43 2009 -0500
+++ b/src/monoize.sml	Tue Dec 22 12:13:23 2009 -0500
@@ -2469,6 +2469,25 @@
                  fm)
             end
 
+          | L.ECApp (
+            (L.ECApp (
+             (L.ECApp (
+              (L.ECApp (
+               (L.EFfi ("Basis", "sql_nullable"), _),
+               _), _),
+              _), _),
+             _), _),
+            _) =>
+            let
+                val s = (L'.TFfi ("Basis", "string"), loc)
+                fun sc s = (L'.EPrim (Prim.String s), loc)
+            in
+                ((L'.EAbs ("u", (L'.TRecord [], loc), (L'.TFun (s, s), loc),
+                           (L'.EAbs ("x", s, s,
+                                     (L'.ERel 0, loc)), loc)), loc),
+                 fm)
+            end
+
           | L.EFfiApp ("Basis", "nextval", [e]) =>
             let
                 val (e, fm) = monoExp (env, st, fm) e