github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/sorterref.test (about)

     1  # 2018 April 14.
     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  
    13  set testdir [file dirname $argv0]
    14  source $testdir/tester.tcl
    15  set testprefix sorterref
    16  
    17  do_execsql_test 1.0 {
    18    CREATE TABLE t1(a, b, c);
    19    INSERT INTO t1 VALUES(1, 2, 3);
    20    INSERT INTO t1 VALUES(4, 5, 6);
    21    ALTER TABLE t1 ADD COLUMN d DEFAULT 'string';
    22    INSERT INTO t1 VALUES(7, 8, 9, 'text');
    23  }
    24  
    25  do_execsql_test 1.1 {
    26    SELECT * FROM t1 ORDER BY b;
    27  } {
    28    1 2 3 string 4 5 6 string 7 8 9 text
    29  }
    30  
    31  do_execsql_test 2.0 {
    32    DROP TABLE IF EXISTS t1;
    33    CREATE TABLE t1(a, b);
    34    CREATE TABLE t2(c, d, PRIMARY KEY(c)) WITHOUT ROWID;
    35  
    36    INSERT INTO t1 VALUES(1, 2);
    37    INSERT INTO t1 VALUES(2, 3);
    38    INSERT INTO t1 VALUES(3, 4);
    39  
    40    INSERT INTO t2 VALUES(1, 'one');
    41    INSERT INTO t2 VALUES(3, 'three');
    42  }
    43  
    44  do_execsql_test 2.1 {
    45    SELECT * FROM t1 LEFT JOIN t2 ON (a=c) ORDER BY b;
    46  } {1 2 1 one 2 3 {} {} 3 4 3 three}
    47  
    48  
    49  
    50  finish_test