comparison tests/policy.ur @ 1228:7dfa67560916

Using multiple policies to check a written value
author Adam Chlipala <adamc@hcoop.net>
date Sun, 11 Apr 2010 16:46:38 -0400
parents 648e6b087dfb
children d5ecceb7d1a1
comparison
equal deleted inserted replaced
1227:1d8fba74e7f5 1228:7dfa67560916
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 (* Everyone may knows IDs and names. *) 11 (* Everyone may knows IDs and names. *)
12 policy sendClient (SELECT fruit.Id, fruit.Nam 12 policy sendClient (SELECT fruit.Id
13 FROM fruit)
14 policy sendClient (SELECT fruit.Nam
13 FROM fruit) 15 FROM fruit)
14 16
15 (* The weight is sensitive information; you must know the secret. *) 17 (* The weight is sensitive information; you must know the secret. *)
16 policy sendClient (SELECT fruit.Weight, fruit.Secret 18 policy sendClient (SELECT fruit.Weight, fruit.Secret
17 FROM fruit 19 FROM fruit
48 FROM fruit, order 50 FROM fruit, order
49 WHERE fruit.Id = order.Fruit 51 WHERE fruit.Id = order.Fruit
50 AND order.Qty = 13) 52 AND order.Qty = 13)
51 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>); 53 (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);
52 54
55 ro <- oneOrNoRows (SELECT fruit.Id, fruit.Nam
56 FROM fruit);
57
53 return <xml><body> 58 return <xml><body>
54 <ul>{x1}</ul> 59 <ul>{x1}</ul>
55 60
56 <ul>{x2}</ul> 61 <ul>{x2}</ul>
62
63 {case ro of
64 None => <xml>None</xml>
65 | Some _ => <xml>Some</xml>}
57 66
58 <form> 67 <form>
59 Fruit name: <textbox{#Nam}/><br/> 68 Fruit name: <textbox{#Nam}/><br/>
60 Secret: <textbox{#Secret}/><br/> 69 Secret: <textbox{#Secret}/><br/>
61 <submit action={fname}/> 70 <submit action={fname}/>