diff options
Diffstat (limited to 'lib/ur')
-rw-r--r-- | lib/ur/top.ur | 13 | ||||
-rw-r--r-- | lib/ur/top.urs | 11 |
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) |