3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. Specifically,
12 # it tests that affinities and collation sequences are correctly applied
13 # in aggregate queries.
15 # $Id: tkt3493.test,v 1.2 2009/06/05 17:09:12 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
23 CREATE TABLE A (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT);
24 INSERT INTO A VALUES(1,'123');
25 INSERT INTO A VALUES(2,'456');
26 CREATE TABLE B (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT);
27 INSERT INTO B VALUES(1,1);
28 INSERT INTO B VALUES(2,2);
29 CREATE TABLE A_B (B_id INTEGER NOT NULL, A_id INTEGER);
30 INSERT INTO A_B VALUES(1,1);
31 INSERT INTO A_B VALUES(2,2);
39 WHEN B.val = 1 THEN 'XYZ'
43 LEFT OUTER JOIN A_B ON B.id = A_B.B_id
44 LEFT OUTER JOIN A ON A.id = A_B.A_id
52 WHEN B.val = 1 THEN 'XYZ'
56 LEFT OUTER JOIN A_B ON B.id = A_B.B_id
57 LEFT OUTER JOIN A ON A.id = A_B.A_id
63 SELECT b.val, CASE WHEN b.val = 1 THEN 'xyz' ELSE b.val END AS col1 FROM b;
70 CASE WHEN b.val = 1 THEN 'xyz' ELSE b.val END AS col1
78 CASE WHEN b.val = '1' THEN 'xyz' ELSE b.val END AS col1
86 CREATE TABLE t1(a TEXT, b INT);
87 INSERT INTO t1 VALUES(123, 456);
90 do_test tkt3493-2.2.1 {
91 execsql { SELECT a=123 FROM t1 GROUP BY a }
93 do_test tkt3493-2.2.2 {
94 execsql { SELECT a=123 FROM t1 }
96 do_test tkt3493-2.2.3 {
97 execsql { SELECT a='123' FROM t1 }
99 do_test tkt3493-2.2.4 {
100 execsql { SELECT count(*), a=123 FROM t1 }
102 do_test tkt3493-2.2.5 {
103 execsql { SELECT count(*), +a=123 FROM t1 }
105 do_test tkt3493-2.3.3 {
106 execsql { SELECT b='456' FROM t1 GROUP BY a }
108 do_test tkt3493-2.3.1 {
109 execsql { SELECT b='456' FROM t1 GROUP BY b }
111 do_test tkt3493-2.3.2 {
112 execsql { SELECT b='456' FROM t1 }
114 do_test tkt3493-2.4.1 {
115 execsql { SELECT typeof(a), a FROM t1 GROUP BY a HAVING a=123 }
117 do_test tkt3493-2.4.2 {
118 execsql { SELECT typeof(a), a FROM t1 GROUP BY b HAVING a=123 }
120 do_test tkt3493-2.5.1 {
121 execsql { SELECT typeof(b), b FROM t1 GROUP BY a HAVING b='456' }
123 do_test tkt3493-2.5.2 {
124 execsql { SELECT typeof(b), b FROM t1 GROUP BY b HAVING b='456' }
127 do_test tkt3493-3.1 {
129 CREATE TABLE t2(a COLLATE NOCASE, b COLLATE BINARY);
130 INSERT INTO t2 VALUES('aBc', 'DeF');
133 do_test tkt3493-3.2.1 {
134 execsql { SELECT a='abc' FROM t2 GROUP BY a }
136 do_test tkt3493-3.2.2 {
137 execsql { SELECT a='abc' FROM t2 }
140 do_test tkt3493-3.3.1 {
141 execsql { SELECT a>b FROM t2 GROUP BY a, b}
143 do_test tkt3493-3.3.2 {
144 execsql { SELECT a>b COLLATE BINARY FROM t2 GROUP BY a, b}
146 do_test tkt3493-3.3.3 {
147 execsql { SELECT b>a FROM t2 GROUP BY a, b}
149 do_test tkt3493-3.3.4 {
150 execsql { SELECT b>a COLLATE NOCASE FROM t2 GROUP BY a, b}