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