# HG changeset patch # User Adam Chlipala # Date 1324141291 18000 # Node ID 2b312f6d4007465b627c4d552e3a374f61f15f36 # Parent 8938f7b315732c2dc65985955e304952a0a776c5 SQL lower() and upper() functions diff -r 8938f7b31573 -r 2b312f6d4007 lib/ur/basis.urs --- 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 diff -r 8938f7b31573 -r 2b312f6d4007 src/monoize.sml --- 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) diff -r 8938f7b31573 -r 2b312f6d4007 tests/lower.ur --- /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 => {[r.A]}
); + return + {all} + diff -r 8938f7b31573 -r 2b312f6d4007 tests/lower.urp --- /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