summaryrefslogtreecommitdiff
path: root/tests/crud.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-11 17:41:52 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-11 17:41:52 -0400
commit48b9d4dae3d1ca6ff39e71571a6db3a43497c9f9 (patch)
tree22ffe528ac30aa133fde37ddcafb13a92cd22357 /tests/crud.ur
parent05fbd01cabc967d7216d8cbe701ac10ad797b122 (diff)
Crud listing IDs
Diffstat (limited to 'tests/crud.ur')
-rw-r--r--tests/crud.ur40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/crud.ur b/tests/crud.ur
new file mode 100644
index 00000000..101b1ba4
--- /dev/null
+++ b/tests/crud.ur
@@ -0,0 +1,40 @@
+functor Make(M : sig
+ con cols :: {Type}
+ constraint [Id] ~ cols
+ val tab : sql_table ([Id = int] ++ cols)
+
+ val title : string
+
+ val cols : $(mapTT (fn t => {Show : t -> xbody}) cols)
+end) = struct
+
+open constraints M
+val tab = M.tab
+
+fun list () =
+ rows <- query (SELECT * FROM tab AS T)
+ (fn fs acc => return <body>
+ {acc} <tr> <td>{txt _ fs.T.Id}</td> </tr>
+ </body>) <body></body>;
+ return <html><head>
+ <title>List</title>
+
+ </head><body>
+
+ <h1>List</h1>
+
+ <table border={1}>
+ <tr> <th>ID</th> </tr>
+ {rows}
+ </table>
+ </body></html>
+
+fun main () : transaction page = return <html><head>
+ <title>{cdata M.title}</title>
+ </head><body>
+ <h1>{cdata M.title}</h1>
+
+ <li> <a link={list ()}>List all rows</a></li>
+</body></html>
+
+end