sl@0: # sl@0: # 2007 June 20 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. The sl@0: # focus of this script is making sure collations pass through the sl@0: # unary + operator. sl@0: # sl@0: # $Id: collate8.test,v 1.2 2008/08/25 12:14:09 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test collate8-1.1 { sl@0: execsql { sl@0: CREATE TABLE t1(a TEXT COLLATE nocase); sl@0: INSERT INTO t1 VALUES('aaa'); sl@0: INSERT INTO t1 VALUES('BBB'); sl@0: INSERT INTO t1 VALUES('ccc'); sl@0: INSERT INTO t1 VALUES('DDD'); sl@0: SELECT a FROM t1 ORDER BY a; sl@0: } sl@0: } {aaa BBB ccc DDD} sl@0: do_test collate8-1.2 { sl@0: execsql { sl@0: SELECT rowid FROM t1 WHERE a<'ccc' ORDER BY 1 sl@0: } sl@0: } {1 2} sl@0: do_test collate8-1.3 { sl@0: execsql { sl@0: SELECT rowid FROM t1 WHERE a<'ccc' COLLATE binary ORDER BY 1 sl@0: } sl@0: } {1 2 4} sl@0: do_test collate8-1.4 { sl@0: execsql { sl@0: SELECT rowid FROM t1 WHERE +a<'ccc' ORDER BY 1 sl@0: } sl@0: } {1 2} sl@0: do_test collate8-1.5 { sl@0: execsql { sl@0: SELECT a FROM t1 ORDER BY +a sl@0: } sl@0: } {aaa BBB ccc DDD} sl@0: do_test collate8-1.11 { sl@0: execsql { sl@0: SELECT a AS x FROM t1 ORDER BY "x"; sl@0: } sl@0: } {aaa BBB ccc DDD} sl@0: do_test collate8-1.12 { sl@0: execsql { sl@0: SELECT a AS x FROM t1 WHERE x<'ccc' ORDER BY 1 sl@0: } sl@0: } {aaa BBB} sl@0: do_test collate8-1.13 { sl@0: execsql { sl@0: SELECT a AS x FROM t1 WHERE x<'ccc' COLLATE binary ORDER BY [x] sl@0: } sl@0: } {aaa BBB DDD} sl@0: do_test collate8-1.14 { sl@0: execsql { sl@0: SELECT a AS x FROM t1 WHERE +x<'ccc' ORDER BY 1 sl@0: } sl@0: } {aaa BBB} sl@0: do_test collate8-1.15 { sl@0: execsql { sl@0: SELECT a AS x FROM t1 ORDER BY +x sl@0: } sl@0: } {aaa BBB ccc DDD} sl@0: sl@0: sl@0: # When a result-set column is aliased into a WHERE clause, make sure the sl@0: # collating sequence logic works correctly. sl@0: # sl@0: do_test collate8-2.1 { sl@0: execsql { sl@0: CREATE TABLE t2(a); sl@0: INSERT INTO t2 VALUES('abc'); sl@0: INSERT INTO t2 VALUES('ABC'); sl@0: SELECT a AS x FROM t2 WHERE x='abc'; sl@0: } sl@0: } {abc} sl@0: do_test collate8-2.2 { sl@0: execsql { sl@0: SELECT a AS x FROM t2 WHERE x='abc' COLLATE nocase; sl@0: } sl@0: } {abc ABC} sl@0: do_test collate8-2.3 { sl@0: execsql { sl@0: SELECT a AS x FROM t2 WHERE (x COLLATE nocase)='abc'; sl@0: } sl@0: } {abc ABC} sl@0: do_test collate8-2.4 { sl@0: execsql { sl@0: SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc'; sl@0: } sl@0: } {abc ABC} sl@0: do_test collate8-2.5 { sl@0: execsql { sl@0: SELECT a COLLATE nocase AS x FROM t2 WHERE (x COLLATE binary)='abc'; sl@0: } sl@0: } {abc} sl@0: do_test collate8-2.6 { sl@0: execsql { sl@0: SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc' COLLATE binary; sl@0: } sl@0: } {abc ABC} sl@0: do_test collate8-2.7 { sl@0: execsql { sl@0: SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary; sl@0: } sl@0: } {abc ABC} sl@0: do_test collate8-2.8 { sl@0: execsql { sl@0: SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary; sl@0: } sl@0: } {abc} sl@0: sl@0: finish_test