summaryrefslogtreecommitdiff
path: root/test/tkt-4ef7e3cfca.test
blob: fc1efdef666f967486c70cd7d307f40f87c10e99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 2014-03-04
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file implements tests to verify that ticket [4ef7e3cfca] has been
# fixed.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix tkt-4ef7e3cfca

do_catchsql_test 1.1 {
  CREATE TABLE x(a);
  CREATE TRIGGER t AFTER INSERT ON x BEGIN
    SELECT * FROM x WHERE abc.a = 1;
  END;
  INSERT INTO x VALUES('assert');
} {1 {no such column: abc.a}}

reset_db
do_execsql_test 2.1 {
  CREATE TABLE w(a);
  CREATE TABLE x(a);
  CREATE TABLE y(a);
  CREATE TABLE z(a);

  INSERT INTO x(a) VALUES(5);
  INSERT INTO y(a) VALUES(10);

  CREATE TRIGGER t AFTER INSERT ON w BEGIN
    INSERT INTO z
    SELECT (SELECT x.a + y.a FROM y) FROM x;
  END;
  INSERT INTO w VALUES('incorrect');
}
do_execsql_test 2.2 {
  SELECT * FROM z;
} {15}

reset_db
do_execsql_test 3.1 {
  CREATE TABLE w(a);
  CREATE TABLE x(b);
  CREATE TABLE y(a);
  CREATE TABLE z(a);

  INSERT INTO x(b) VALUES(5);
  INSERT INTO y(a) VALUES(10);

  CREATE TRIGGER t AFTER INSERT ON w BEGIN
    INSERT INTO z
    SELECT (SELECT x.b + y.a FROM y) FROM x;
  END;
  INSERT INTO w VALUES('assert');
}
do_execsql_test 3.2 {
  SELECT * FROM z;
} {15}

finish_test