tkt-3a77c9714e.test 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # 2011 December 06
  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. # This file implements regression tests for SQLite library.
  12. #
  13. # This file implements tests to verify that ticket [3a77c9714e] has been
  14. # fixed.
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. ifcapable !compound {
  18. finish_test
  19. return
  20. }
  21. set testprefix "tkt-3a77c9714e"
  22. do_execsql_test 1.1 {
  23. CREATE TABLE t1(t1_id INTEGER PRIMARY KEY, t1_title TEXT);
  24. CREATE TABLE t2(t2_id INTEGER PRIMARY KEY, t2_title TEXT);
  25. CREATE TABLE t3(t3_id INTEGER PRIMARY KEY, t3_title TEXT);
  26. INSERT INTO t1 (t1_id, t1_title) VALUES (888, 'ABCDEF');
  27. INSERT INTO t2 (t2_id, t2_title) VALUES (999, 'ABCDEF');
  28. INSERT INTO t3 (t3_id, t3_title) VALUES (999, 'ABCDEF');
  29. }
  30. do_execsql_test 1.2 {
  31. SELECT t1_title, t2_title
  32. FROM t1 LEFT JOIN t2
  33. WHERE
  34. t2_id = (SELECT t3_id FROM
  35. ( SELECT t3_id FROM t3 WHERE t3_title=t1_title LIMIT 500 )
  36. )
  37. } {ABCDEF ABCDEF}
  38. do_execsql_test 2.1 {
  39. CREATE TABLE [Beginnings] (
  40. [Id] INTEGER PRIMARY KEY AUTOINCREMENT,[Title] TEXT, [EndingId] INTEGER
  41. );
  42. CREATE TABLE [Endings] (Id INT,Title TEXT,EndingId INT);
  43. INSERT INTO Beginnings (Id, Title, EndingId) VALUES (1, 'FACTOR', 18);
  44. INSERT INTO Beginnings (Id, Title, EndingId) VALUES (2, 'SWIMM', 18);
  45. INSERT INTO Endings (Id, Title, EndingId) VALUES (1, 'ING', 18);
  46. }
  47. do_execsql_test 2.2 {
  48. SELECT
  49. SrcWord, Beginnings.Title
  50. FROM
  51. (SELECT 'FACTORING' AS SrcWord UNION SELECT 'SWIMMING' AS SrcWord )
  52. LEFT JOIN
  53. Beginnings
  54. WHERE Beginnings.Id= (
  55. SELECT BeginningId FROM (
  56. SELECT SrcWord, B.Id as BeginningId, B.Title || E.Title As Connected
  57. FROM Beginnings B LEFT JOIN Endings E ON B.EndingId=E.EndingId
  58. WHERE Connected=SrcWord LIMIT 1
  59. )
  60. )
  61. } {FACTORING FACTOR SWIMMING SWIMM}
  62. finish_test