summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-26 10:53:36 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-26 10:53:36 -0400
commiteb733a5e57d1248c18651208da7b5078031ac1f3 (patch)
tree741eea8099c56fc61347f867ce538744a95c2b8f /tests
parent4f288849df2bb1a5a1d9d6f6ec9537badd82b6ab (diff)
Handling nullable blobs
Diffstat (limited to 'tests')
-rw-r--r--tests/blobOpt.ur38
-rw-r--r--tests/blobOpt.urp5
-rw-r--r--tests/blobOpt.urs1
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/blobOpt.ur b/tests/blobOpt.ur
new file mode 100644
index 00000000..261ce226
--- /dev/null
+++ b/tests/blobOpt.ur
@@ -0,0 +1,38 @@
+sequence s
+table t : { Id : int, Data : option blob, Typ : string }
+
+fun view id =
+ r <- oneRow (SELECT t.Data, t.Typ FROM t WHERE t.Id = {[id]});
+ case r.T.Data of
+ None => return <xml>This one's empty.</xml>
+ | Some data => returnBlob data (blessMime r.T.Typ)
+
+fun save r =
+ id <- nextval s;
+ dml (INSERT INTO t (Id, Data, Typ)
+ VALUES ({[id]}, {[Some (fileData r.Data)]}, {[fileMimeType r.Data]}));
+ main ()
+
+and saveEmpty () =
+ id <- nextval s;
+ dml (INSERT INTO t (Id, Data, Typ)
+ VALUES ({[id]}, {[None]}, "bogus"));
+ main ()
+
+and main () =
+ ls <- queryX (SELECT t.Id FROM t)
+ (fn r => <xml><li><a link={view r.T.Id}>{[r.T.Id]}</a></li></xml>);
+ return <xml><body>
+ {ls}
+
+ <br/>
+
+ <form>
+ <upload{#Data}/>
+ <submit action={save}/>
+ </form>
+
+ <form>
+ <submit action={saveEmpty}/>
+ </form>
+ </body></xml>
diff --git a/tests/blobOpt.urp b/tests/blobOpt.urp
new file mode 100644
index 00000000..fef3c5d2
--- /dev/null
+++ b/tests/blobOpt.urp
@@ -0,0 +1,5 @@
+debug
+database dbname=blobopt
+sql blobOpt.sql
+
+blobOpt
diff --git a/tests/blobOpt.urs b/tests/blobOpt.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/tests/blobOpt.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page