summaryrefslogtreecommitdiff
path: root/tests/policy.ur
diff options
context:
space:
mode:
Diffstat (limited to 'tests/policy.ur')
-rw-r--r--tests/policy.ur25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/policy.ur b/tests/policy.ur
index bc4da5be..b821d1d1 100644
--- a/tests/policy.ur
+++ b/tests/policy.ur
@@ -1,12 +1,27 @@
-table fruit : { Id : int, Nam : string, Weight : float, Secret : string }
+type fruit = int
+table fruit : { Id : fruit, Nam : string, Weight : float, Secret : string }
+ PRIMARY KEY Id,
+ CONSTRAINT Nam UNIQUE Nam
+
+type order = int
+table order : { Id : order, Fruit : fruit, Qty : int, Code : int }
+ PRIMARY KEY Id,
+ CONSTRAINT Fruit FOREIGN KEY Fruit REFERENCES fruit(Id)
policy query_policy (SELECT fruit.Id, fruit.Nam, fruit.Weight FROM fruit)
+policy query_policy (SELECT order.Id, order.Fruit, order.Qty FROM order)
fun main () =
- xml <- queryX (SELECT fruit.Id, fruit.Nam
- FROM fruit)
- (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);
+ x1 <- queryX (SELECT fruit.Id, fruit.Nam
+ FROM fruit)
+ (fn x => <xml><li>{[x.Fruit.Id]}: {[x.Fruit.Nam]}</li></xml>);
+
+ x2 <- queryX (SELECT fruit.Nam, order.Qty
+ FROM fruit, order
+ WHERE order.Fruit = fruit.Id)
+ (fn x => <xml><li>{[x.Fruit.Nam]}: {[x.Order.Qty]}</li></xml>);
return <xml><body>
- {xml}
+ <ul>{x1}</ul>
+ <ul>{x2}</ul>
</body></xml>