summaryrefslogtreecommitdiff
path: root/tests/limit.ur
blob: 2079b47ca59a11cb0c0b6cdfb2490a4e21c38d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
table t : {A : int, B : string, C : float}

val q1 = (SELECT * FROM t LIMIT 42)
val q2 = fn n => (SELECT * FROM t LIMIT {n})

val q3 = (SELECT * FROM t OFFSET 3)
val q4 = fn n => fn m => (SELECT * FROM t LIMIT {n} OFFSET {m})


datatype list a = Nil | Cons of a * list a

val r1 : transaction (list {A : int, B : string, C : float}) =
        query (q4 3 7)
        (fn fs acc => return (Cons (fs.T, acc)))
        Nil

val r2 : transaction string =
        ls <- r1;
        return (case ls of
                    Nil => "Problem"
                  | Cons ({B = b, ...}, _) => b)

val main : unit -> transaction page = fn () =>
        s <- r2;
        return <html><body>
                {cdata s}
        </body></html>