OLD | NEW |
1 # 2002 May 24 | 1 # 2002 May 24 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # This file implements regression tests for SQLite library. | 11 # This file implements regression tests for SQLite library. |
12 # | 12 # |
13 # This file implements tests for joins, including outer joins. | 13 # This file implements tests for joins, including outer joins. |
14 # | 14 # |
15 # $Id: join2.test,v 1.2 2005/01/21 03:12:16 danielk1977 Exp $ | |
16 | 15 |
17 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
18 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
| 18 set testprefix join2 |
19 | 19 |
20 do_test join2-1.1 { | 20 do_test join2-1.1 { |
21 execsql { | 21 execsql { |
22 CREATE TABLE t1(a,b); | 22 CREATE TABLE t1(a,b); |
23 INSERT INTO t1 VALUES(1,11); | 23 INSERT INTO t1 VALUES(1,11); |
24 INSERT INTO t1 VALUES(2,22); | 24 INSERT INTO t1 VALUES(2,22); |
25 INSERT INTO t1 VALUES(3,33); | 25 INSERT INTO t1 VALUES(3,33); |
26 SELECT * FROM t1; | 26 SELECT * FROM t1; |
27 } | 27 } |
28 } {1 11 2 22 3 33} | 28 } {1 11 2 22 3 33} |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } {1 11 111 1111} | 65 } {1 11 111 1111} |
66 ifcapable subquery { | 66 ifcapable subquery { |
67 do_test join2-1.7 { | 67 do_test join2-1.7 { |
68 execsql { | 68 execsql { |
69 SELECT * FROM | 69 SELECT * FROM |
70 t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3) | 70 t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3) |
71 } | 71 } |
72 } {1 11 111 1111 2 22 {} {} 3 33 {} {}} | 72 } {1 11 111 1111 2 22 {} {} 3 33 {} {}} |
73 } | 73 } |
74 | 74 |
| 75 #------------------------------------------------------------------------- |
| 76 # Check that ticket [25e335f802ddc] has been resolved. It should be an |
| 77 # error for the ON clause of a LEFT JOIN to refer to a table to its right. |
| 78 # |
| 79 do_execsql_test 2.0 { |
| 80 CREATE TABLE aa(a); |
| 81 CREATE TABLE bb(b); |
| 82 CREATE TABLE cc(c); |
| 83 INSERT INTO aa VALUES('one'); |
| 84 INSERT INTO bb VALUES('one'); |
| 85 INSERT INTO cc VALUES('one'); |
| 86 } |
| 87 |
| 88 do_catchsql_test 2.1 { |
| 89 SELECT * FROM aa LEFT JOIN cc ON (a=b) JOIN bb ON (b=c); |
| 90 } {1 {ON clause references tables to its right}} |
| 91 do_catchsql_test 2.2 { |
| 92 SELECT * FROM aa JOIN cc ON (a=b) JOIN bb ON (b=c); |
| 93 } {0 {one one one}} |
| 94 |
75 finish_test | 95 finish_test |
OLD | NEW |