#!sqlite3 # # 2025-11-12 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # Test cases for the ".mode" command of the CLI. # To run these tests: # # ./sqlite3 test/modeA.sql # # .open :memory: CREATE TABLE t1(a,b,c,d,e); INSERT INTO t1 VALUES(1,2.5,'three',x'4444',NULL); INSERT INTO t1 SELECT b,c,d,e,a FROM t1; INSERT INTO t1 SELECT d,e,a,b,c FROM t1; .mode box .testcase 100 SELECT * FROM t1; .check < n null END .testcase 551 .mode html --null XX SELECT NULL AS n; .check < n XX END .testcase 552 .nullvalue YY SELECT NULL AS n; .check < n YY END .testcase 553 .nullvalue SELECT NULL AS n; .check -glob "*sage: .nullvalue STRING*" # NULL text is HTML-escaped, and does not change how a string that # happens to look like the NULL text is rendered. .testcase 554 .mode html --null SELECT NULL AS n, 'null' AS m; .check < n m <nil> null END # Switching to another mode and back restores the default for html. .testcase 555 .mode list --null XX .mode html SELECT NULL AS n; .check < n null END .mode line --titlelimit 3 .nullvalue "" # With "--escape off" a control character in a value is shown by the # columnar modes as a one-column Control Picture symbol. Column widths # must count it as one column, so that the value is not wrapped. # Bug 2026-11-05T22:27:00Z. # .testcase 560 .mode box --escape off SELECT 'a'||char(7)||'b' AS x; .check <',5); .mode box .testcase 1700 .mode --quote json SELECT a, b FROM t1; .check <" │ 5 │ ╰───────────┴───╯ END .mode box .testcase 1710 .mode --quote html SELECT a, b FROM t1; .check <" │ 5 │ ╰───────────┴───╯ END .mode box .testcase 1730 .mode --quote tcl SELECT a, b FROM t1; .check <" │ 5 │ ╰───────────┴───╯ END .mode box .testcase 1740 .mode --quote list SELECT a, b FROM t1; .check '<"x">|5' # Bug https://sqlite.org/bugs/forumpost/3ade505a97 # BLOB values must be rendered validly in JSON and INSERT output even if # the text-quoting mode is changed. # .mode --reset json .mode --quote relaxed .testcase 1800 SELECT -42 AS id, X'4142' AS raw; .check <