1 # 2001 September 15 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 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. 9 # 10 #*********************************************************************** 11 # 12 # Tests to make sure #3997 is fixed. 13 # 14 # $Id: tkt3997.test,v 1.1 2009/07/28 13:30:31 danielk1977 Exp $ 15 16 set testdir [file dirname $argv0] 17 source $testdir/tester.tcl 18 19 proc reverse {lhs rhs} { 20 return [string compare $rhs $lhs] 21 } 22 proc usual {lhs rhs} { 23 return [string compare $lhs $rhs] 24 } 25 26 db collate reverse reverse 27 db collate usual usual 28 29 do_test tkt3997-1.1 { 30 execsql { 31 create table mytext(name BLOB); 32 INSERT INTO mytext VALUES('abc'); 33 INSERT INTO mytext VALUES('acd'); 34 INSERT INTO mytext VALUES('afe'); 35 } 36 } {} 37 do_test tkt3997-1.2 { 38 execsql { 39 SELECT name 40 FROM mytext 41 ORDER BY name COLLATE reverse 42 } 43 } {afe acd abc} 44 do_test tkt3997-1.3 { 45 execsql { 46 SELECT name 47 FROM (SELECT name FROM mytext) 48 ORDER BY name COLLATE reverse 49 } 50 } {afe acd abc} 51 52 do_test tkt3997-2.1 { 53 execsql { 54 CREATE TABLE mytext2(name COLLATE reverse); 55 INSERT INTO mytext2 SELECT name FROM mytext; 56 } 57 } {} 58 do_test tkt3997-2.2 { 59 execsql { 60 SELECT name 61 FROM (SELECT name FROM mytext2) 62 ORDER BY name 63 } 64 } {afe acd abc} 65 do_test tkt3997-2.3 { 66 execsql { 67 SELECT name 68 FROM (SELECT name FROM mytext2) 69 ORDER BY name COLLATE usual 70 } 71 } {abc acd afe} 72 73 finish_test 74