summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2013-09-13 10:24:10 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2013-09-13 10:24:10 -0400
commit081e9e2304f084f58ec91ae6ea278d75bc7a7d57 (patch)
tree0fb1418d845cdeac2a2910d51d39adf337d33cbe /tests
parent77df2d7165287246cb982d5a61ec92dce442b635 (diff)
Tweak Sergey's patch to work with Postgres
Diffstat (limited to 'tests')
-rw-r--r--tests/dbupload.ur25
-rw-r--r--tests/dbupload.urp6
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/dbupload.ur b/tests/dbupload.ur
new file mode 100644
index 00000000..f088d63b
--- /dev/null
+++ b/tests/dbupload.ur
@@ -0,0 +1,25 @@
+table t : { Id : int, Blob : blob, MimeType : string }
+sequence s
+
+fun getImage id : transaction page =
+ r <- oneRow1 (SELECT t.Blob, t.MimeType
+ FROM t
+ WHERE t.Id = {[id]});
+ returnBlob r.Blob (blessMime r.MimeType)
+
+fun main () : transaction page =
+ let
+ fun handle r =
+ id <- nextval s;
+ dml (INSERT INTO t (Id, Blob, MimeType)
+ VALUES ({[id]}, {[fileData r.File]}, {[fileMimeType r.File]}));
+ main ()
+ in
+ x <- queryX1 (SELECT t.Id FROM t)
+ (fn r => <xml><img src={url (getImage r.Id)}/><br/></xml>);
+ return <xml><body>
+ <form><upload{#File}/> <submit action={handle}/></form>
+ <hr/>
+ {x}
+ </body></xml>
+ end
diff --git a/tests/dbupload.urp b/tests/dbupload.urp
new file mode 100644
index 00000000..dd8417d1
--- /dev/null
+++ b/tests/dbupload.urp
@@ -0,0 +1,6 @@
+database dbname=dbupload
+sql dbupload.sql
+allow mime *
+rewrite all Dbupload/*
+
+dbupload