tkt2141.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # 2007 January 03
  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 #2141 has been
  14. # fixed.
  15. #
  16. #
  17. # $Id: tkt2141.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $
  18. set testdir [file dirname $argv0]
  19. source $testdir/tester.tcl
  20. ifcapable !subquery {
  21. finish_test
  22. return
  23. }
  24. do_test tkt2141-1.1 {
  25. execsql {
  26. CREATE TABLE tab1 (t1_id integer PRIMARY KEY, t1_desc);
  27. INSERT INTO tab1 VALUES(1,'rec 1 tab 1');
  28. CREATE TABLE tab2 (t2_id integer PRIMARY KEY, t2_id_t1, t2_desc);
  29. INSERT INTO tab2 VALUES(1,1,'rec 1 tab 2');
  30. CREATE TABLE tab3 (t3_id integer PRIMARY KEY, t3_id_t2, t3_desc);
  31. INSERT INTO tab3 VALUES(1,1,'aa');
  32. SELECT *
  33. FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1
  34. WHERE t2.t2_id IN
  35. (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2
  36. WHERE t3_id IN (1,2) GROUP BY t2_id);
  37. }
  38. } {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}
  39. do_test tkt2141-1.2 {
  40. execsql {
  41. SELECT *
  42. FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1
  43. WHERE t2.t2_id IN
  44. (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2
  45. WHERE t3_id IN (1,2));
  46. }
  47. } {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}
  48. do_test tkt2141-1.3 {
  49. execsql {
  50. SELECT *
  51. FROM tab1 t1 LEFT JOIN tab2 t2
  52. WHERE t2.t2_id IN
  53. (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2
  54. WHERE t3_id IN (1,2));
  55. }
  56. } {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}
  57. finish_test