Home | History | Annotate | Download | only in test
      1 # 2007 Dec 12
      2 #
      3 # The author disclaims copyright to this source code. In place of
      4 # a legal notice, here is a blessing:
      5 #
      6 #    May you do good and not evil.
      7 #    May you find forgiveness for yourself and forgive others.
      8 #    May you share freely, never taking more than you give.
      9 #
     10 #***********************************************************************
     11 #
     12 # This file is to test that ticket #2832 has been fixed.
     13 #
     14 # $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $
     15 #
     16 
     17 set testdir [file dirname $argv0]
     18 source $testdir/tester.tcl
     19 
     20 ifcapable !trigger { finish_test ; return }
     21 
     22 do_test tkt2832-1.1 {
     23   execsql {
     24     CREATE TABLE t1(a PRIMARY KEY);
     25     INSERT INTO t1 VALUES(2);
     26     INSERT INTO t1 VALUES(1);
     27     INSERT INTO t1 VALUES(3);
     28   }
     29 } {}
     30 do_test tkt2832-1.2 {
     31   execsql {
     32     UPDATE OR REPLACE t1 SET a = 1;
     33     SELECT * FROM t1;
     34   }
     35 } {1}
     36 
     37 do_test tkt2832-2.1 {
     38   execsql {
     39     CREATE TABLE t2(a, b);
     40     CREATE TRIGGER t2_t AFTER UPDATE ON t2 BEGIN
     41       DELETE FROM t2 WHERE a = new.a + 1;
     42     END;
     43     INSERT INTO t2 VALUES(1, 2);
     44     INSERT INTO t2 VALUES(2, 3);
     45   }
     46 } {}
     47 do_test tkt2832-2.2 {
     48   execsql { 
     49     UPDATE t2 SET b = 5 
     50   }
     51 } {}
     52 
     53 do_test tkt2832-3.1 {
     54   execsql {
     55     CREATE TABLE t3(a, b);
     56     CREATE TRIGGER t3_t AFTER DELETE ON t3 BEGIN
     57       DELETE FROM t3 WHERE a = old.a + 1;
     58     END;
     59     INSERT INTO t3 VALUES(1, 2);
     60     INSERT INTO t3 VALUES(2, 3);
     61   }
     62 } {}
     63 do_test tkt2832-3.2 {
     64   execsql { DELETE FROM t3 WHERE 1 }
     65 } {}
     66 
     67 finish_test
     68