diff tests/cst.ur @ 709:0406e9cccb72

FOREIGN KEY, without ability to link NULL to NOT NULL (and with some lingering problems in row inference)
author Adam Chlipala <adamc@hcoop.net>
date Tue, 07 Apr 2009 18:47:47 -0400
parents d8217b4cb617
children 915ec60592d4
line wrap: on
line diff
--- a/tests/cst.ur	Tue Apr 07 16:22:11 2009 -0400
+++ b/tests/cst.ur	Tue Apr 07 18:47:47 2009 -0400
@@ -1,3 +1,7 @@
+table u : {C : int, D : int, E : int}
+  PRIMARY KEY C,
+  CONSTRAINT U UNIQUE (C, D)
+
 table t : {A : int, B : int}
   PRIMARY KEY B,
 
@@ -11,7 +15,19 @@
 
   CONSTRAINT UniBothm UNIQUE ({#A}, {#B}),
   CONSTRAINT UniBothm2 {unique [#A] [[B = _]] ! !},
-  {{one_constraint [#UniBothm3] (unique [#A] [[B = _]] ! !)}}
+  {{one_constraint [#UniBothm3] (unique [#A] [[B = _]] ! !)}},
+
+  CONSTRAINT ForA FOREIGN KEY A REFERENCES u (C),
+  CONSTRAINT ForAB FOREIGN KEY (A, B) REFERENCES u (D, C) ON DELETE CASCADE ON UPDATE RESTRICT,
+  CONSTRAINT ForBA FOREIGN KEY (A, B) REFERENCES u (C, D) ON UPDATE NO ACTION,
+
+  CONSTRAINT Self FOREIGN KEY B REFERENCES t (B)
+
+table s : {B : option int}
+  CONSTRAINT UniB UNIQUE B
+
+table s2 : {B : option int}
+  CONSTRAINT ForB FOREIGN KEY B REFERENCES s (B) ON DELETE SET NULL
 
 fun main () : transaction page =
     queryI (SELECT * FROM t) (fn _ => return ());