comparison 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
comparison
equal deleted inserted replaced
1203:a75c66dd2aeb 1204:7af5e2af64f4
1 table fruit : { Id : int, Nam : string, Weight : float, Secret : string } 1 type fruit = int
2 table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string }
3 PRIMARY KEY Id,
4 CONSTRAINT Nam UNIQUE Nam
5
6 type order = int
7 table order : { Id : order, Fruit : fruit, Qty : int, Code : int }
8 PRIMARY KEY Id,
9 CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id)
2 10
3 policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight FROM fruit) 11 policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight FROM fruit)
12 policy query_policy (SELECT order.Id, order.Fruit, order.Qty FROM order)
4 13
5 fun main () = 14 fun main () =
6 xml <- queryX (SELECT fruit.Id, fruit.Nam 15 x1 <- queryX (SELECT fruit.Id, fruit.Nam
7 FROM fruit) 16 FROM fruit)
8 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>); 17 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);
18
19 x2 <- queryX (SELECT fruit.Nam, order.Qty
20 FROM fruit, order
21 WHERE order.Fruit = fruit.Id)
22 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);
9 23
10 return <xml><body> 24 return <xml><body>
11 {xml} 25 <ul>{x1}</ul>
26 <ul>{x2}</ul>
12 </body></xml> 27 </body></xml>