| OLD | NEW |
| 1 # | 1 # |
| 2 # 2007 June 20 | 2 # 2007 June 20 |
| 3 # | 3 # |
| 4 # The author disclaims copyright to this source code. In place of | 4 # The author disclaims copyright to this source code. In place of |
| 5 # a legal notice, here is a blessing: | 5 # a legal notice, here is a blessing: |
| 6 # | 6 # |
| 7 # May you do good and not evil. | 7 # May you do good and not evil. |
| 8 # May you find forgiveness for yourself and forgive others. | 8 # May you find forgiveness for yourself and forgive others. |
| 9 # May you share freely, never taking more than you give. | 9 # May you share freely, never taking more than you give. |
| 10 # | 10 # |
| 11 #*********************************************************************** | 11 #*********************************************************************** |
| 12 # This file implements regression tests for SQLite library. The | 12 # This file implements regression tests for SQLite library. The |
| 13 # focus of this script is making sure collations pass through the | 13 # focus of this script is making sure collations pass through the |
| 14 # unary + operator. | 14 # unary + operator. |
| 15 # | 15 # |
| 16 # $Id: collate8.test,v 1.2 2008/08/25 12:14:09 drh Exp $ | 16 # 2015-02-09: Added tests to make sure COLLATE passes through function |
| 17 # calls. Ticket [ca0d20b6cdddec5e81b8d66f89c46a5583b5f6f6]. |
| 18 # |
| 17 | 19 |
| 18 set testdir [file dirname $argv0] | 20 set testdir [file dirname $argv0] |
| 19 source $testdir/tester.tcl | 21 source $testdir/tester.tcl |
| 20 | 22 |
| 21 do_test collate8-1.1 { | 23 do_test collate8-1.1 { |
| 22 execsql { | 24 execsql { |
| 23 CREATE TABLE t1(a TEXT COLLATE nocase); | 25 CREATE TABLE t1(a TEXT COLLATE nocase); |
| 24 INSERT INTO t1 VALUES('aaa'); | 26 INSERT INTO t1 VALUES('aaa'); |
| 25 INSERT INTO t1 VALUES('BBB'); | 27 INSERT INTO t1 VALUES('BBB'); |
| 26 INSERT INTO t1 VALUES('ccc'); | 28 INSERT INTO t1 VALUES('ccc'); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 execsql { | 117 execsql { |
| 116 SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary; | 118 SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary; |
| 117 } | 119 } |
| 118 } {abc ABC} | 120 } {abc ABC} |
| 119 do_test collate8-2.8 { | 121 do_test collate8-2.8 { |
| 120 execsql { | 122 execsql { |
| 121 SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary; | 123 SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary; |
| 122 } | 124 } |
| 123 } {abc} | 125 } {abc} |
| 124 | 126 |
| 127 # Make sure the COLLATE operator perculates up through function calls |
| 128 # and other Expr structures that use the Expr.x.pList field. |
| 129 # |
| 130 do_execsql_test collate8-3.1 { |
| 131 SELECT 'abc'==('ABC'||'') COLLATE nocase; |
| 132 SELECT 'abc'==('ABC'||'' COLLATE nocase); |
| 133 SELECT 'abc'==('ABC'||('' COLLATE nocase)); |
| 134 SELECT 'abc'==('ABC'||upper('' COLLATE nocase)); |
| 135 } {1 1 1 1} |
| 136 do_execsql_test collate8-3.2 { |
| 137 SELECT 'abc'==('ABC'||max('' COLLATE nocase,'' COLLATE binary)); |
| 138 } {1} |
| 139 |
| 140 # The COLLATE binary is on the left and so takes precedence |
| 141 do_execsql_test collate8-3.3 { |
| 142 SELECT 'abc'==('ABC'||max('' COLLATE binary,'' COLLATE nocase)); |
| 143 } {0} |
| 144 |
| 145 do_execsql_test collate8-3.4 { |
| 146 SELECT 'abc'==('ABC'||CASE WHEN 1-1=2 THEN '' COLLATE nocase |
| 147 ELSE '' COLLATE binary END); |
| 148 SELECT 'abc'==('ABC'||CASE WHEN 1+1=2 THEN '' COLLATE nocase |
| 149 ELSE '' COLLATE binary END); |
| 150 } {1 1} |
| 151 do_execsql_test collate8-3.5 { |
| 152 SELECT 'abc'==('ABC'||CASE WHEN 1=2 THEN '' COLLATE binary |
| 153 ELSE '' COLLATE nocase END); |
| 154 } {0} |
| 155 |
| 156 |
| 125 finish_test | 157 finish_test |
| OLD | NEW |