summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ur/basis.urs7
-rw-r--r--lib/ur/top.ur20
2 files changed, 7 insertions, 20 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index d6b27852..586c5ef9 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -207,15 +207,12 @@ val sql_int : sql_injectable_prim int
val sql_float : sql_injectable_prim float
val sql_string : sql_injectable_prim string
val sql_time : sql_injectable_prim time
-
-class sql_injectable_nullable
-val sql_channel : t ::: Type -> sql_injectable_nullable (channel t)
-val sql_client : sql_injectable_nullable client
+val sql_channel : t ::: Type -> sql_injectable_prim (channel t)
+val sql_client : sql_injectable_prim client
class sql_injectable
val sql_prim : t ::: Type -> sql_injectable_prim t -> sql_injectable t
val sql_option_prim : t ::: Type -> sql_injectable_prim t -> sql_injectable (option t)
-val sql_nullable : t ::: Type -> sql_injectable_nullable t -> sql_injectable (option t)
val sql_inject : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
-> t ::: Type
diff --git a/lib/ur/top.ur b/lib/ur/top.ur
index 5465da3d..154e88e9 100644
--- a/lib/ur/top.ur
+++ b/lib/ur/top.ur
@@ -200,7 +200,7 @@ fun eqNullable' (tables ::: {{Type}}) (agg ::: {{Type}}) (exps ::: {Type})
functor Broadcast(M : sig type t end) = struct
sequence s
- table t : {Id : int, Client : option client, Channel : option (channel M.t)}
+ table t : {Id : int, Client : client, Channel : channel M.t}
type topic = int
@@ -208,27 +208,17 @@ functor Broadcast(M : sig type t end) = struct
val create = nextval s
- val cleanup =
- dml (DELETE FROM t WHERE Client IS NULL)
-
fun subscribe id =
cli <- self;
- cleanup;
- ro <- oneOrNoRows (SELECT t.Channel FROM t WHERE t.Id = {[id]} AND t.Client = {[Some cli]});
+ ro <- oneOrNoRows (SELECT t.Channel FROM t WHERE t.Id = {[id]} AND t.Client = {[cli]});
case ro of
None =>
ch <- channel;
- dml (INSERT INTO t (Id, Client, Channel) VALUES ({[id]}, {[Some cli]}, {[Some ch]}));
+ dml (INSERT INTO t (Id, Client, Channel) VALUES ({[id]}, {[cli]}, {[ch]}));
return ch
- | Some r =>
- case r.T.Channel of
- None => error <xml>Broadcast.subscribe: Got null result</xml>
- | Some ch => return ch
+ | Some r => return r.T.Channel
fun send id msg =
- cleanup;
queryI (SELECT t.Channel FROM t WHERE t.Id = {[id]})
- (fn r => case r.T.Channel of
- None => error <xml>Broadcast.send: Got null result</xml>
- | Some ch => Basis.send ch msg)
+ (fn r => Basis.send r.T.Channel msg)
end