4 # The author disclaims copyright to this source code. In place of
5 # a legal notice, here is a blessing:
7 # May you do good and not evil.
8 # May you find forgiveness for yourself and forgive others.
9 # May you share freely, never taking more than you give.
11 #***********************************************************************
12 # This file implements regression tests for SQLite library. The
13 # focus of this script is making sure collations pass through the
16 # $Id: collate8.test,v 1.2 2008/08/25 12:14:09 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 do_test collate8-1.1 {
23 CREATE TABLE t1(a TEXT COLLATE nocase);
24 INSERT INTO t1 VALUES('aaa');
25 INSERT INTO t1 VALUES('BBB');
26 INSERT INTO t1 VALUES('ccc');
27 INSERT INTO t1 VALUES('DDD');
28 SELECT a FROM t1 ORDER BY a;
31 do_test collate8-1.2 {
33 SELECT rowid FROM t1 WHERE a<'ccc' ORDER BY 1
36 do_test collate8-1.3 {
38 SELECT rowid FROM t1 WHERE a<'ccc' COLLATE binary ORDER BY 1
41 do_test collate8-1.4 {
43 SELECT rowid FROM t1 WHERE +a<'ccc' ORDER BY 1
46 do_test collate8-1.5 {
48 SELECT a FROM t1 ORDER BY +a
51 do_test collate8-1.11 {
53 SELECT a AS x FROM t1 ORDER BY "x";
56 do_test collate8-1.12 {
58 SELECT a AS x FROM t1 WHERE x<'ccc' ORDER BY 1
61 do_test collate8-1.13 {
63 SELECT a AS x FROM t1 WHERE x<'ccc' COLLATE binary ORDER BY [x]
66 do_test collate8-1.14 {
68 SELECT a AS x FROM t1 WHERE +x<'ccc' ORDER BY 1
71 do_test collate8-1.15 {
73 SELECT a AS x FROM t1 ORDER BY +x
78 # When a result-set column is aliased into a WHERE clause, make sure the
79 # collating sequence logic works correctly.
81 do_test collate8-2.1 {
84 INSERT INTO t2 VALUES('abc');
85 INSERT INTO t2 VALUES('ABC');
86 SELECT a AS x FROM t2 WHERE x='abc';
89 do_test collate8-2.2 {
91 SELECT a AS x FROM t2 WHERE x='abc' COLLATE nocase;
94 do_test collate8-2.3 {
96 SELECT a AS x FROM t2 WHERE (x COLLATE nocase)='abc';
99 do_test collate8-2.4 {
101 SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc';
104 do_test collate8-2.5 {
106 SELECT a COLLATE nocase AS x FROM t2 WHERE (x COLLATE binary)='abc';
109 do_test collate8-2.6 {
111 SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc' COLLATE binary;
114 do_test collate8-2.7 {
116 SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary;
119 do_test collate8-2.8 {
121 SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary;