xref: /sqlite-3.40.0/test/nulls1.test (revision 6e11892d)
1# 2019 August 10
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
14####################################################
15# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
16####################################################
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20set testprefix nulls1
21
22do_execsql_test 1.0 {
23  DROP TABLE IF EXISTS t3;
24  CREATE TABLE t3(a INTEGER);
25  INSERT INTO t3 VALUES(NULL), (10), (30), (20), (NULL);
26} {}
27
28for {set a 0} {$a < 2} {incr a} {
29  foreach {tn limit} {
30    1 ""
31    2 "LIMIT 10"
32  } {
33    do_execsql_test 1.$a.$tn.1 "
34      SELECT a FROM t3 ORDER BY a nULLS FIRST $limit
35    " {{}   {}   10   20   30}
36
37    do_execsql_test 1.$a.$tn.2 "
38      SELECT a FROM t3 ORDER BY a nULLS LAST $limit
39    " {10   20   30   {}   {}}
40
41    do_execsql_test 1.$a.$tn.3 "
42      SELECT a FROM t3 ORDER BY a DESC nULLS FIRST $limit
43    " {{}   {}   30   20   10}
44
45    do_execsql_test 1.$a.$tn.4 "
46      SELECT a FROM t3 ORDER BY a DESC nULLS LAST $limit
47    " {30   20   10   {}   {}}
48  }
49
50  catchsql { CREATE INDEX i1 ON t3(a) }
51}
52
53finish_test
54