| OLD | NEW |
| 1 # | 1 # |
| 2 # 2001 September 15 | 2 # 2001 September 15 |
| 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 page cache subsystem. | 13 # focus of this script is testing collation sequences. |
| 14 # | 14 # |
| 15 # $Id: collate1.test,v 1.5 2007/02/01 23:02:46 drh Exp $ | |
| 16 | 15 |
| 17 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
| 18 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
| 18 set testprefix collate1 |
| 19 | 19 |
| 20 # | 20 # |
| 21 # Tests are roughly organised as follows: | 21 # Tests are roughly organised as follows: |
| 22 # | 22 # |
| 23 # collate1-1.* - Single-field ORDER BY with an explicit COLLATE clause. | 23 # collate1-1.* - Single-field ORDER BY with an explicit COLLATE clause. |
| 24 # collate1-2.* - Multi-field ORDER BY with an explicit COLLATE clause. | 24 # collate1-2.* - Multi-field ORDER BY with an explicit COLLATE clause. |
| 25 # collate1-3.* - ORDER BY using a default collation type. Also that an | 25 # collate1-3.* - ORDER BY using a default collation type. Also that an |
| 26 # explict collate type overrides a default collate type. | 26 # explict collate type overrides a default collate type. |
| 27 # collate1-4.* - ORDER BY using a data type. | 27 # collate1-4.* - ORDER BY using a data type. |
| 28 # | 28 # |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 execsql { | 326 execsql { |
| 327 SELECT id FROM c5 WHERE b='abc' ORDER BY id; | 327 SELECT id FROM c5 WHERE b='abc' ORDER BY id; |
| 328 } | 328 } |
| 329 } {1} | 329 } {1} |
| 330 do_test collate1-5.3 { | 330 do_test collate1-5.3 { |
| 331 execsql { | 331 execsql { |
| 332 SELECT id FROM c5 WHERE c='abc' ORDER BY id; | 332 SELECT id FROM c5 WHERE c='abc' ORDER BY id; |
| 333 } | 333 } |
| 334 } {1 2} | 334 } {1 2} |
| 335 | 335 |
| 336 |
| 337 |
| 338 #------------------------------------------------------------------------- |
| 339 # Fix problems with handling collation sequences named '"""'. |
| 340 # |
| 341 do_execsql_test 6.1 { |
| 342 SELECT """"""""; |
| 343 } {\"\"\"} |
| 344 |
| 345 do_catchsql_test 6.2 { |
| 346 CREATE TABLE x1(a); |
| 347 SELECT a FROM x1 ORDER BY a COLLATE """"""""; |
| 348 } {1 {no such collation sequence: """}} |
| 349 |
| 350 do_catchsql_test 6.3 { |
| 351 SELECT a FROM x1 ORDER BY 1 COLLATE """"""""; |
| 352 } {1 {no such collation sequence: """}} |
| 353 |
| 354 do_catchsql_test 6.4 { |
| 355 SELECT 0 UNION SELECT 0 ORDER BY 1 COLLATE """"""""; |
| 356 } {1 {no such collation sequence: """}} |
| 357 |
| 358 db collate {"""} [list string compare -nocase] |
| 359 |
| 360 do_execsql_test 6.5 { |
| 361 PRAGMA foreign_keys = ON; |
| 362 CREATE TABLE p1(a PRIMARY KEY COLLATE '"""'); |
| 363 CREATE TABLE c1(x, y REFERENCES p1); |
| 364 } {} |
| 365 |
| 366 do_execsql_test 6.6 { |
| 367 INSERT INTO p1 VALUES('abc'); |
| 368 INSERT INTO c1 VALUES(1, 'ABC'); |
| 369 } |
| 370 |
| 371 ifcapable foreignkey { |
| 372 do_catchsql_test 6.7 { |
| 373 DELETE FROM p1 WHERE rowid = 1 |
| 374 } {1 {FOREIGN KEY constraint failed}} |
| 375 } |
| 376 |
| 377 do_execsql_test 6.8 { |
| 378 INSERT INTO p1 VALUES('abb'); |
| 379 INSERT INTO p1 VALUES('wxz'); |
| 380 INSERT INTO p1 VALUES('wxy'); |
| 381 |
| 382 INSERT INTO c1 VALUES(2, 'abb'); |
| 383 INSERT INTO c1 VALUES(3, 'wxz'); |
| 384 INSERT INTO c1 VALUES(4, 'WXY'); |
| 385 SELECT x, y FROM c1 ORDER BY y COLLATE """"""""; |
| 386 } {2 abb 1 ABC 4 WXY 3 wxz} |
| 387 |
| 336 finish_test | 388 finish_test |
| 389 |
| 390 |
| OLD | NEW |