summaryrefslogtreecommitdiff
path: root/tests/policy.ur
blob: b821d1d11574e257cc1ff518cb844fc0db1745b5 (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
type fruit = int
table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string }
  PRIMARY KEY Id,
  CONSTRAINT Nam UNIQUE Nam

type order = int
table order : { Id : order, Fruit : fruit, Qty : int, Code : int }
  PRIMARY KEY Id,
  CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id)

policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight FROM fruit)
policy query_policy (SELECT order.Id, order.Fruit, order.Qty FROM order)

fun main () =
    x1 <- queryX (SELECT fruit.Id, fruit.Nam
                  FROM fruit)
                 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);

    x2 <- queryX (SELECT fruit.Nam, order.Qty
                  FROM fruit, order
                  WHERE order.Fruit = fruit.Id)
                 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);

    return <xml><body>
      <ul>{x1}</ul>
      <ul>{x2}</ul>
    </body></xml>