annotate tests/policy.ur @ 1205:7cd11380cdf1

WHERE-dependent checking
author Adam Chlipala <adamc@hcoop.net>
date Sun, 04 Apr 2010 17:18:41 -0400
parents 7af5e2af64f4
children 772760df4c4c
rev   line source
adamc@1204 1 type fruit = int
adamc@1204 2 table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string }
adamc@1204 3 PRIMARY KEY Id,
adamc@1204 4 CONSTRAINT Nam UNIQUE Nam
adamc@1204 5
adamc@1204 6 type order = int
adamc@1204 7 table order : { Id : order, Fruit : fruit, Qty : int, Code : int }
adamc@1204 8 PRIMARY KEY Id,
adamc@1204 9 CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id)
adamc@1199 10
adamc@1205 11 policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight
adamc@1205 12 FROM fruit)
adamc@1205 13 policy query_policy (SELECT order.Id, order.Fruit, order.Qty
adamc@1205 14 FROM order, fruit
adamc@1205 15 WHERE order.Fruit = fruit.Id)
adamc@1200 16
adamc@1200 17 fun main () =
adamc@1204 18 x1 <- queryX (SELECT fruit.Id, fruit.Nam
adamc@1204 19 FROM fruit)
adamc@1204 20 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);
adamc@1204 21
adamc@1204 22 x2 <- queryX (SELECT fruit.Nam, order.Qty
adamc@1204 23 FROM fruit, order
adamc@1205 24 WHERE fruit.Id = order.Fruit)
adamc@1204 25 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);
adamc@1200 26
adamc@1200 27 return <xml><body>
adamc@1204 28 <ul>{x1}</ul>
adamc@1204 29 <ul>{x2}</ul>
adamc@1200 30 </body></xml>