annotate tests/policy.ur @ 1204:7af5e2af64f4

Parsed a WHERE clause
author Adam Chlipala <adamc@hcoop.net>
date Sun, 04 Apr 2010 17:11:22 -0400
parents a75c66dd2aeb
children 7cd11380cdf1
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@1203 11 policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight FROM fruit)
adamc@1204 12 policy query_policy (SELECT order.Id, order.Fruit, order.Qty FROM order)
adamc@1200 13
adamc@1200 14 fun main () =
adamc@1204 15 x1 <- queryX (SELECT fruit.Id, fruit.Nam
adamc@1204 16 FROM fruit)
adamc@1204 17 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);
adamc@1204 18
adamc@1204 19 x2 <- queryX (SELECT fruit.Nam, order.Qty
adamc@1204 20 FROM fruit, order
adamc@1204 21 WHERE order.Fruit = fruit.Id)
adamc@1204 22 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);
adamc@1200 23
adamc@1200 24 return <xml><body>
adamc@1204 25 <ul>{x1}</ul>
adamc@1204 26 <ul>{x2}</ul>
adamc@1200 27 </body></xml>