changeset 1636:2b312f6d4007

SQL lower() and upper() functions
author Adam Chlipala <adam@chlipala.net>
date Sat, 17 Dec 2011 12:01:31 -0500
parents 8938f7b31573
children e374b6b8ab38
files lib/ur/basis.urs src/monoize.sml tests/lower.ur tests/lower.urp
diffstat 4 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/basis.urs	Sat Dec 17 09:24:31 2011 -0500
+++ b/lib/ur/basis.urs	Sat Dec 17 12:01:31 2011 -0500
@@ -565,7 +565,8 @@
                 -> sql_exp tables agg exps ran
 val sql_octet_length : sql_ufunc blob int
 val sql_known : t ::: Type -> sql_ufunc t bool
-
+val sql_lower : sql_ufunc string string
+val sql_upper : sql_ufunc string string
 
 val sql_nullable : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} -> t ::: Type
                    -> sql_injectable_prim t
--- a/src/monoize.sml	Sat Dec 17 09:24:31 2011 -0500
+++ b/src/monoize.sml	Sat Dec 17 12:01:31 2011 -0500
@@ -2785,6 +2785,10 @@
                                          "octet_length"
                                      else
                                          "length")), loc), fm)
+          | L.EFfi ("Basis", "sql_lower") =>
+            ((L'.EPrim (Prim.String "lower"), loc), fm)
+          | L.EFfi ("Basis", "sql_upper") =>
+            ((L'.EPrim (Prim.String "upper"), loc), fm)
           | L.ECApp ((L.EFfi ("Basis", "sql_known"), _), _) =>
             ((L'.EFfi ("Basis", "sql_known"), loc), fm)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lower.ur	Sat Dec 17 12:01:31 2011 -0500
@@ -0,0 +1,10 @@
+table lower : { A : string }
+
+fun main () : transaction page =
+    all <- queryX1 (SELECT *
+                    FROM lower
+                    WHERE lower(lower.A) LIKE '%foo')
+                   (fn r => <xml>{[r.A]}<br/></xml>);
+    return <xml><body>
+      {all}
+    </body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lower.urp	Sat Dec 17 12:01:31 2011 -0500
@@ -0,0 +1,4 @@
+database dbname=test
+sql lower.sql
+
+lower