summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-10-20 11:05:58 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-10-20 11:05:58 -0400
commite23f4d764bc93640cb08a7d6ebd7e261fac2cb05 (patch)
treed11bc3451bff30a58f66c2d1dbb41852526a308f /lib
parent66fa98fe9619afa56b10f1357edb617dc813051c (diff)
Registering for Conference1
Diffstat (limited to 'lib')
-rw-r--r--lib/ur/top.ur13
-rw-r--r--lib/ur/top.urs11
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/ur/top.ur b/lib/ur/top.ur
index a2395d4f..6ffc888f 100644
--- a/lib/ur/top.ur
+++ b/lib/ur/top.ur
@@ -236,11 +236,16 @@ fun queryX' [tables ::: {{Type}}] [exps ::: {Type}] [ctx ::: {Unit}]
fun oneOrNoRows [tables ::: {{Type}}] [exps ::: {Type}]
[tables ~ exps]
- (q : sql_query tables exps) =
+ (q : sql_query tables exps) =
query q
(fn fs _ => return (Some fs))
None
+fun oneOrNoRows1 [nm ::: Name] [fs ::: {Type}] (q : sql_query [nm = fs] []) =
+ query q
+ (fn fs _ => return (Some fs.nm))
+ None
+
fun oneRow [tables ::: {{Type}}] [exps ::: {Type}]
[tables ~ exps] (q : sql_query tables exps) =
o <- oneOrNoRows q;
@@ -248,6 +253,12 @@ fun oneRow [tables ::: {{Type}}] [exps ::: {Type}]
None => error <xml>Query returned no rows</xml>
| Some r => r)
+fun oneRowE1 [tab ::: Name] [nm ::: Name] [t ::: Type] [[tab] ~ [nm]] (q : sql_query [tab = []] [nm = t]) =
+ o <- oneOrNoRows q;
+ return (case o of
+ None => error <xml>Query returned no rows</xml>
+ | Some r => r.nm)
+
fun eqNullable [tables ::: {{Type}}] [agg ::: {{Type}}] [exps ::: {Type}]
[t ::: Type] (_ : sql_injectable (option t))
(e1 : sql_exp tables agg exps (option t))
diff --git a/lib/ur/top.urs b/lib/ur/top.urs
index ef907760..82090dd2 100644
--- a/lib/ur/top.urs
+++ b/lib/ur/top.urs
@@ -147,13 +147,22 @@ val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type}
$(exps
++ map (fn fields :: {Type} => $fields) tables))
+val oneOrNoRows1 : nm ::: Name -> fs ::: {Type}
+ -> sql_query [nm = fs] []
+ -> transaction (option $fs)
+
val oneRow : tables ::: {{Type}} -> exps ::: {Type}
-> [tables ~ exps] =>
sql_query tables exps
-> transaction
$(exps
++ map (fn fields :: {Type} => $fields) tables)
-
+
+val oneRowE1 : tab ::: Name -> nm ::: Name -> t ::: Type
+ -> [[tab] ~ [nm]] =>
+ sql_query [tab = []] [nm = t]
+ -> transaction t
+
val eqNullable : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
-> t ::: Type -> sql_injectable (option t)
-> sql_exp tables agg exps (option t)