Mercurial > urweb
annotate tests/policy.ur @ 1206:772760df4c4c
Parsing more of WHERE
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 04 Apr 2010 17:44:12 -0400 |
parents | 7cd11380cdf1 |
children | ae3036773768 |
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@1206 | 15 WHERE order.Fruit = fruit.Id |
adamc@1206 | 16 AND order.Qty = 13) |
adamc@1200 | 17 |
adamc@1200 | 18 fun main () = |
adamc@1204 | 19 x1 <- queryX (SELECT fruit.Id, fruit.Nam |
adamc@1204 | 20 FROM fruit) |
adamc@1204 | 21 (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>); |
adamc@1204 | 22 |
adamc@1204 | 23 x2 <- queryX (SELECT fruit.Nam, order.Qty |
adamc@1204 | 24 FROM fruit, order |
adamc@1206 | 25 WHERE fruit.Id = order.Fruit |
adamc@1206 | 26 AND order.Qty = 13) |
adamc@1204 | 27 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>); |
adamc@1200 | 28 |
adamc@1200 | 29 return <xml><body> |
adamc@1204 | 30 <ul>{x1}</ul> |
adamc@1204 | 31 <ul>{x2}</ul> |
adamc@1200 | 32 </body></xml> |