sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / test / complete_sql.sql
| 1 | #!sqlite3 |
| 2 | # |
| 3 | # 2026-10-08 |
| 4 | # |
| 5 | # The author disclaims copyright to this source code. In place of |
| 6 | # a legal notice, here is a blessing: |
| 7 | # |
| 8 | # May you do good and not evil. |
| 9 | # May you find forgiveness for yourself and forgive others. |
| 10 | # May you share freely, never taking more than you give. |
| 11 | # |
| 12 | #*********************************************************************** |
| 13 | # |
| 14 | # Test cases for the "shell_complete_sql()" function in the CLI. |
| 15 | # |
| 16 | # ./sqlite3 test/complete_sql.sql |
| 17 | # |
| 18 | # |
| 19 | .open :memory: |
| 20 | .mode -reset test |
| 21 | .testcase 100 |
| 22 | .mode line --limits off |
| 23 | SELECT shell_complete_sql('CREATE TABLE t1(a) /*') AS out; |
| 24 | .check <<END |
| 25 | out: CREATE TABLE t1(a) /**/ |
| 26 | END |
| 27 | |
| 28 | .testcase 110 |
| 29 | SELECT shell_complete_sql('CREATE TABLE t1(a) --') AS out; |
| 30 | .check <<END |
| 31 | out: CREATE TABLE t1(a) -- |
| 32 | |
| 33 | END |
| 34 | |
| 35 | .testcase 120 |
| 36 | SELECT shell_complete_sql('CREATE TABLE t1(a CHECK(a<>''/*''))') AS out; |
| 37 | .check <<END |
| 38 | out: CREATE TABLE t1(a CHECK(a<>'/*')) |
| 39 | END |
| 40 | |
| 41 | .testcase 130 |
| 42 | SELECT shell_complete_sql('CREATE TABLE t1(a) ''one') AS out; |
| 43 | .check <<END |
| 44 | out: CREATE TABLE t1(a) 'one' |
| 45 | END |
| 46 | |
| 47 | .testcase 140 |
| 48 | SELECT shell_complete_sql('CREATE TABLE t1(a) "one') AS out; |
| 49 | .check <<END |
| 50 | out: CREATE TABLE t1(a) "one" |
| 51 | END |
| 52 | |
| 53 | .testcase 150 |
| 54 | SELECT shell_complete_sql('CREATE TABLE t1(a) `one') AS out; |
| 55 | .check <<END |
| 56 | out: CREATE TABLE t1(a) `one` |
| 57 | END |
| 58 | |
| 59 | .testcase 160 |
| 60 | SELECT shell_complete_sql('CREATE TABLE t1(a) [one') AS out; |
| 61 | .check <<END |
| 62 | out: CREATE TABLE t1(a) [one] |
| 63 | END |
| 64 | |
| 65 | .testcase 170 |
| 66 | SELECT shell_complete_sql('CREATE TRIGGER t1(a) [one') AS out; |
| 67 | .check <<END |
| 68 | out: CREATE TRIGGER t1(a) [one];END |
| 69 | END |
| 70 | |
| 71 | .testcase 180 |
| 72 | SELECT shell_complete_sql('CREATE TRIGGER t1(a) [one]') AS out; |
| 73 | .check <<END |
| 74 | out: CREATE TRIGGER t1(a) [one];END |
| 75 | END |
| 76 | |
| 77 | .testcase 190 |
| 78 | SELECT shell_complete_sql('CREATE TRIGGER t1(a) [one];') AS out; |
| 79 | .check <<END |
| 80 | out: CREATE TRIGGER t1(a) [one];END |
| 81 | END |
| 82 | |
| 83 | .testcase 200 |
| 84 | SELECT shell_complete_sql('CREATE TABLE t1(a);') AS out; |
| 85 | .check <<END |
| 86 | out: CREATE TABLE t1(a); |
| 87 | END |
| 88 | |
| 89 | .testcase 210 |
| 90 | SELECT shell_complete_sql(' ') AS out; |
| 91 | .check <<END |
| 92 | out: |
| 93 | END |
| 94 | |
| 95 | .testcase 220 |
| 96 | SELECT shell_complete_sql(' /* only') AS out; |
| 97 | .check <<END |
| 98 | out: /* only*/ |
| 99 | END |
| 100 | |
| 101 | .testcase 300 |
| 102 | SELECT shell_complete_sql('SELECT (((''',1) AS out; |
| 103 | .check <<END |
| 104 | out: SELECT (((''))); |
| 105 | END |
| 106 | |
| 107 | .testcase 310 |
| 108 | SELECT shell_complete_sql('SELECT (((/*',1) AS out; |
| 109 | .check <<END |
| 110 | out: SELECT (((/**/))); |
| 111 | END |
| 112 | |
| 113 | .testcase 320 |
| 114 | SELECT shell_complete_sql('SELECT (((/*',3) AS out; |
| 115 | .check <<END |
| 116 | out: */))); |
| 117 | END |