Mercurial > urweb
changeset 1072:9001966ae1c8
Weakening-type coercions for SQL values
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 13 Dec 2009 13:00:55 -0500 |
parents | 26197c957ad6 |
children | b2311dfb3158 |
files | lib/ur/basis.urs lib/ur/top.ur lib/ur/top.urs src/monoize.sml |
diffstat | 4 files changed, 57 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ur/basis.urs Sun Dec 13 11:28:47 2009 -0500 +++ b/lib/ur/basis.urs Sun Dec 13 13:00:55 2009 -0500 @@ -256,6 +256,11 @@ -> sql_constraint ([mine1 = t] ++ mine ++ munused) [] con sql_exp :: {{Type}} -> {{Type}} -> {Type} -> Type -> Type +val sql_exp_weaken : fs ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} -> t ::: Type + -> fs' ::: {{Type}} -> agg' ::: {{Type}} -> exps' ::: {Type} + -> [fs ~ fs'] => [agg ~ agg'] => [exps ~ exps'] => + sql_exp fs agg exps t + -> sql_exp (fs ++ fs') (agg ++ agg') (exps ++ exps') t val check : fs ::: {Type} -> sql_exp [] [] fs bool @@ -274,6 +279,12 @@ (map (fn fields :: ({Type} * {Type}) => fields.1 ++ fields.2) keep_drop) (map (fn fields :: ({Type} * {Type}) => fields.1) keep_drop) val sql_subset_all : tables :: {{Type}} -> sql_subset tables tables +val sql_subset_concat : big1 ::: {{Type}} -> little1 ::: {{Type}} + -> big2 ::: {{Type}} -> little2 ::: {{Type}} + -> [big1 ~ big2] => [little1 ~ little2] => + sql_subset big1 little1 + -> sql_subset big2 little2 + -> sql_subset (big1 ++ big2) (little1 ++ little2) con sql_from_items :: {{Type}} -> Type @@ -343,10 +354,10 @@ -> sql_relop -> sql_query1 tables1 selectedFields selectedExps -> sql_query1 tables2 selectedFields selectedExps - -> sql_query1 selectedFields selectedFields selectedExps + -> sql_query1 [] selectedFields selectedExps val sql_forget_tables : tables ::: {{Type}} -> selectedFields ::: {{Type}} -> selectedExps ::: {Type} -> sql_query1 tables selectedFields selectedExps - -> sql_query1 selectedFields selectedFields selectedExps + -> sql_query1 [] selectedFields selectedExps type sql_direction val sql_asc : sql_direction
--- a/lib/ur/top.ur Sun Dec 13 11:28:47 2009 -0500 +++ b/lib/ur/top.ur Sun Dec 13 13:00:55 2009 -0500 @@ -234,6 +234,13 @@ return <xml>{acc}{r}</xml>) <xml/> +fun hasRows [tables ::: {{Type}}] [exps ::: {Type}] + [tables ~ exps] + (q : sql_query tables exps) = + query q + (fn _ _ => return True) + False + fun oneOrNoRows [tables ::: {{Type}}] [exps ::: {Type}] [tables ~ exps] (q : sql_query tables exps) =
--- a/lib/ur/top.urs Sun Dec 13 11:28:47 2009 -0500 +++ b/lib/ur/top.urs Sun Dec 13 13:00:55 2009 -0500 @@ -139,6 +139,11 @@ -> transaction (xml ctx inp [])) -> transaction (xml ctx inp []) +val hasRows : tables ::: {{Type}} -> exps ::: {Type} + -> [tables ~ exps] => + sql_query tables exps + -> transaction bool + val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type} -> [tables ~ exps] => sql_query tables exps
--- a/src/monoize.sml Sun Dec 13 11:28:47 2009 -0500 +++ b/src/monoize.sml Sun Dec 13 13:00:55 2009 -0500 @@ -1587,6 +1587,28 @@ fm) end + | L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.ECApp ( + (L.EFfi ("Basis", "sql_exp_weaken"), _), + _), _), + _), _), + _), _), + _), _), + _), _), + _), _), + _) => + let + val string = (L'.TFfi ("Basis", "string"), loc) + in + ((L'.EAbs ("e", string, string, (L'.ERel 0, loc)), loc), + fm) + end + | L.ECApp ((L.EFfi ("Basis", "check"), _), _) => let val string = (L'.TFfi ("Basis", "string"), loc) @@ -1993,6 +2015,16 @@ ((L'.ERecord [], loc), fm) | L.ECApp ((L.EFfi ("Basis", "sql_subset_all"), _), _) => ((L'.ERecord [], loc), fm) + | L.ECApp ((L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_subset_concat"), + _), _), _), _), _), _), _), _) => + let + val un = (L'.TRecord [], loc) + in + ((L'.EAbs ("_", un, (L'.TFun (un, un), loc), + (L'.EAbs ("_", un, un, + (L'.ERecord [], loc)), loc)), loc), + fm) + end | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "fieldsOf_table"), _), _), _), _) => ((L'.ERecord [], loc), fm)