diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-12-17 12:01:31 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-12-17 12:01:31 -0500 |
commit | c9b985223bc94657127b48fa3370bff4ea6ed5f3 (patch) | |
tree | 9979ef0b3677541c9738b8545ab89d958248daf2 | |
parent | cc9303c6ce89d762a93119cae93241f0485829ac (diff) |
SQL lower() and upper() functions
-rw-r--r-- | lib/ur/basis.urs | 3 | ||||
-rw-r--r-- | src/monoize.sml | 4 | ||||
-rw-r--r-- | tests/lower.ur | 10 | ||||
-rw-r--r-- | tests/lower.urp | 4 |
4 files changed, 20 insertions, 1 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index fcce3a01..83f23cae 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -565,7 +565,8 @@ val sql_ufunc : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} -> 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 --git a/src/monoize.sml b/src/monoize.sml index e4ed6562..b1cccb81 100644 --- a/src/monoize.sml +++ b/src/monoize.sml @@ -2785,6 +2785,10 @@ fun monoExp (env, st, fm) (all as (e, loc)) = "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 --git a/tests/lower.ur b/tests/lower.ur new file mode 100644 index 00000000..21e1f1f6 --- /dev/null +++ b/tests/lower.ur @@ -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> diff --git a/tests/lower.urp b/tests/lower.urp new file mode 100644 index 00000000..6abf57aa --- /dev/null +++ b/tests/lower.urp @@ -0,0 +1,4 @@ +database dbname=test +sql lower.sql + +lower |