]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved title separator in QRF when using "-title always" on an empty row.
authordrh <>
Tue, 7 Jul 2026 12:24:50 +0000 (12:24 +0000)
committerdrh <>
Tue, 7 Jul 2026 12:24:50 +0000 (12:24 +0000)
Improved comments on the mode matrix in the CLI code.  Additional test
cases.

FossilOrigin-Name: a102d28fca6376da670b274d3d733da2c73da9abe3e7128defd04b4015b03a48

ext/qrf/qrf.c
manifest
manifest.uuid
src/shell.c.in
test/modeA.sql
test/qrf01.test

index 6efb1c8ada9c238ebd58f2eed144691910a71be6..c90a134c137a1b0c9ad04018d3cedff192f116f4 100644 (file)
@@ -1648,6 +1648,10 @@ static void qrfRowSeparator(sqlite3_str *pOut, qrfColData *p, char cSep){
 #define DBL_123  "\342\225\236"  /* U+255e  |= */
 #define DBL_134  "\342\225\241"  /* U+2561 =|  */
 #define DBL_1234 "\342\225\252"  /* U+256a =|= */
+#define DBL_12   "\342\225\230"  /* U+2558  `= */
+#define DBL_14   "\342\225\233"  /* U+255b ='  */
+#define DBL_124  "\342\225\247"  /* U+2567 ='= */
+
 
 /* Draw horizontal line N characters long using unicode box
 ** characters
@@ -1670,12 +1674,12 @@ static void qrfBoxLine(sqlite3_str *pOut, int N, int bDbl){
 ** Draw a horizontal separator for a QRF_STYLE_Box table.
 */
 static void qrfBoxSeparator(
-  sqlite3_str *pOut,
-  qrfColData *p,
-  const char *zSep1,
-  const char *zSep2,
-  const char *zSep3,
-  int bDbl
+  sqlite3_str *pOut,    /* Output to this sqlite3_str */
+  qrfColData *p,        /* Columnar data */
+  const char *zSep1,    /* Left margin */
+  const char *zSep2,    /* Column separator */
+  const char *zSep3,    /* Right margin */
+  int bDbl              /* True for double-lines */
 ){
   int i;
   if( p->nCol>0 ){
@@ -1695,6 +1699,32 @@ static void qrfBoxSeparator(
   sqlite3_str_append(pOut, "\n", 1);
 }
 
+/*
+** Draw a horizontal separator for a QRF_STYLE_Column table.
+** This style of separator is only used for separating the title
+** from the content.
+*/
+static void qrfColumnSeparator(
+  sqlite3_str *pOut,    /* Output to this sqlite3_str */
+  qrfColData *p,        /* Columnar data */
+  const char *colSep,   /* Column separator text */
+  int szColSep,         /* Size of zColSep in bytes */
+  const char *rowSep,   /* Row separator text */
+  int szRowSep          /* Size of zRowSep in bytes */
+){
+  int j;
+  int nColumn = p->nCol;
+  for(j=0; j<nColumn; j++){
+    sqlite3_str_appendchar(pOut, p->a[j].w, '-');
+    if( j<nColumn-1 ){
+      sqlite3_str_append(pOut, colSep, szColSep);
+    }else{
+      qrfRTrim(pOut);
+      sqlite3_str_append(pOut, rowSep, szRowSep);
+    }
+  }
+}
+
 /*
 ** Load into pData the default alignment for the body of a table.
 */
@@ -2269,15 +2299,8 @@ static void qrfColumnar(Qrf *p){
         }
         case QRF_STYLE_Column: {
           if( isTitleDataSeparator ){
-            for(j=0; j<nColumn; j++){
-              sqlite3_str_appendchar(p->pOut, data.a[j].w, '-');
-              if( j<nColumn-1 ){
-                sqlite3_str_append(p->pOut, colSep, szColSep);
-              }else{
-                qrfRTrim(p->pOut);
-                sqlite3_str_append(p->pOut, rowSep, szRowSep);
-              }
-            }
+            qrfColumnSeparator(p->pOut, &data, colSep, szColSep,
+                                               rowSep, szRowSep);
           }else if( data.bMultiRow ){
             qrfRTrim(p->pOut);
             sqlite3_str_append(p->pOut, "\n", 1);
@@ -2292,11 +2315,21 @@ static void qrfColumnar(Qrf *p){
   if( p->spec.bBorder!=QRF_No || p->nRow==0 ){
     switch( p->spec.eStyle ){
       case QRF_STYLE_Box:
-        qrfBoxSeparator(p->pOut, &data, BOX_R12, BOX_124, BOX_R14, 0);
+        if( p->nRow>0 ){
+          qrfBoxSeparator(p->pOut, &data, BOX_R12, BOX_124, BOX_R14, 0);
+        }else{
+          qrfBoxSeparator(p->pOut, &data, DBL_12,  DBL_124, DBL_14,  1);
+        }
         break;
       case QRF_STYLE_Table:
         qrfRowSeparator(p->pOut, &data, '+');
         break;
+      case QRF_STYLE_Column:
+        if( p->nRow==0 ){
+          qrfColumnSeparator(p->pOut, &data, colSep, szColSep,
+                                             rowSep, szRowSep);
+        }
+        break;
     }
   }
   if( p->spec.bRowCount==QRF_Yes ){
index 61f6efa70ea6e7e4145c1ed45e5b72ce85addccb..e516045294baea198f08dab37e0a8cd4a9aed19e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Show\s--rowcount\sfor\s"--style\sinsert".\s\sNew\stest\scases.
-D 2026-07-07T11:00:10.684
+C Improved\stitle\sseparator\sin\sQRF\swhen\susing\s"-title\salways"\son\san\sempty\srow.\nImproved\scomments\son\sthe\smode\smatrix\sin\sthe\sCLI\scode.\s\sAdditional\stest\ncases.
+D 2026-07-07T12:24:50.291
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -425,7 +425,7 @@ F ext/misc/zipfile.c 5cf901996c840b32a5c03d947c4ee86bda166f6e595a41871840df85204
 F ext/misc/zorder.c bddff2e1b9661a90c95c2a9a9c7ecd8908afab5763256294dd12d609d4664eee
 F ext/qrf/README.md 3dfd5de860cdc0c572d8926ba0c1b3cc8925487dfbda10e63af66a8811907687
 F ext/qrf/dev-notes.md e68a6d91ce4c7eb296ef2daadc2bb79c95c317ad15b9fafe40850c67b29c2430
-F ext/qrf/qrf.c 660da110dcf6e0b458fba4ac5d6609b633efc6dddd64e2bc5af7f8a0579b7475
+F ext/qrf/qrf.c e8c8ff93bb834c28921e6b021922750f4fa6ed929f39b95c1137029e141ef25e
 F ext/qrf/qrf.h fcbc33578176b2fd9dda8310d8f6ba4eaf4f75052f466dfe682802e6664df8bd
 F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
 F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
@@ -743,7 +743,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c 54395ee97eb710e695202d4112cf2b1c1c7767a57afcea745df71abb1c917768
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c f553420eaf5c72a49cef786621eea79dd8c4411671839fb05250bb49ca74a0a0
-F src/shell.c.in ad7b45289ca6867ca2d87230aefc5acc63b86511f9605f23765b0129105e5576
+F src/shell.c.in c6ec9326fff4986734aa00d5aa38d4cf486f651a6765aceb04e30cda580d0810
 F src/sqlite.h.in d9ec41feb4cd804e68b174328b43beb3f1f71bba13e1c7a439efb826d301cccc
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 0efd4723bad9124ea1f581d9f1ea0254ac1c6f3e5fb29e4f3dcf36c72485a456
@@ -1461,7 +1461,7 @@ F test/mmap4.test 2e2b4e32555b58da15176e6fe750f17c9dcf7f93
 F test/mmapcorrupt.test 470fb44fe92e99c1d23701d156f8c17865f5b027063c9119dcfdb842791f4465
 F test/mmapfault.test d4c9eff9cd8c2dc14bc43e71e042f175b0a26fe3
 F test/mmapwarm.test 2272005969cd17a910077bd5082f70bc1fefad9a875afec7fc9af483898ecaf3
-F test/modeA.sql eda688a95bfed5da5b8516ada67db3b696e903cd5bd2a0b900300cb2e5f64451
+F test/modeA.sql 07e757d4e28ab20217d4350544cb752845886807bfd5a4c2ccc3c471340fd797
 F test/multiplex.test d74c034e52805f6de8cc5432cef8c9eb774bb64ec29b83a22effc8ca4dac1f08
 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
 F test/multiplex3.test fac575e0b1b852025575a6a8357701d80933e98b5d2fe6d35ddaa68f92f6a1f7
@@ -1533,7 +1533,7 @@ F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224c
 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb
 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
 F test/pushdown.test 46a626ef1c0ca79b85296ff2e078b9da20a50e9b804b38f441590c3987580ddd
-F test/qrf01.test dafebb59e6aa6523b5bf6ff64d1992bbf869be9c221fb18567a67d04874f69ca
+F test/qrf01.test 6fcb3d252d2a855eba4fa5d64002286fdafe40b8fb608337c041b60865f9f636
 F test/qrf02.test 39b4afdc000bedccdafc0aecf17638df67a67aaa2d2942865ae6abcc48ba0e92
 F test/qrf03.test e7efe46d204671726b4707585126cd78d107368de4a7d0c7b8d5157cdd8624ed
 F test/qrf04.test 0894692c998d2401dcc33449c02051b503ecce0c94217be54fb007c82d2d1379
@@ -2213,8 +2213,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P adeb4fbb86a8a781d7efb0eecb9c84ce605d0bd45f63992bf2ecd60765a60d2c
-R f7fdf80c6283e7cb9c051183725987bf
+P 386c40e3a9706111542b7f336e82f7bb6e9f43c6056185f9f3bd9aae1159070a
+R 97c4c759605f34012aa08b81926f369d
 U drh
-Z 2ec65d5f66458affd3eb44f92e876b01
+Z 0742604b3741cfad8c5b1bef622a5b3f
 # Remove this line to create a well-formed Fossil manifest.
index cffa2e7ba87e242a062ec78f28165d4562078156..b12c53f6679dcc47b3cebcafd0bd3a78a75d1624 100644 (file)
@@ -1 +1 @@
-386c40e3a9706111542b7f336e82f7bb6e9f43c6056185f9f3bd9aae1159070a
+a102d28fca6376da670b274d3d733da2c73da9abe3e7128defd04b4015b03a48
index c9ebae848cac25064c0d10a0436671fb38a42c49..5536ab32fc17dd52425eff7b5439857fa68bce13 100644 (file)
@@ -602,19 +602,19 @@ static const ModeInfo aModeInfo[] = {
   { "tabs",     8,     1,    9,    3,    3,    0,   1,   12,    0,  0 },
   { "tcl",      3,     1,    12,   5,    5,    4,   1,   12,    0,  0 },
   { "www",      0,     0,    9,    4,    4,    0,   2,   7,     0,  0 }
-};     /*       |     /     /      |     /    /     |    |       \
-       **       |    /     /       |    /    /      |    |        \_ 2: columnar
-       ** Index into aModeStr[]    |   /    /       |    |           1: line
-       **                          |  /    /        |    |           0: other
-       **                          | /    /         |     \
-       **           text encoding  |/     |    show |      \
-       **      v-------------------'      |   hdrs? |       The QRF style
-       **      0: n/a                blob |   v-----'
-       **      1: plain        v----------'   0: n/a
-       **      2: sql          0: auto        1: no         
-       **      3: csv          1: as-text     2: yes
-       **      4: html         2: sql         3: always
-       **      5: c            3: hex
+};     /*       |     /     /      |     /    /     |    |     /     \____
+       **       |    /     /       |    /    /      |    |    /           |
+       ** Index into aModeStr[]    |   /    /       |    |  2: columnar   |
+       **                          |  /    /        |    |  1: line       |
+       **                          | /    /         |    |  0: other      |
+       **           text encoding  |/     |    show |    |                |
+       **      v-------------------'      |   hdrs? |    The QRF style    |
+       **      0: n/a                blob |   v-----'                    /
+       **      1: plain        v----------'   0: n/a           _________/
+       **      2: sql          0: auto        1: no           |
+       **      3: csv          1: as-text     2: yes          1: border-off +
+       **      4: html         2: sql         3: always          title-always
+       **      5: c            3: hex                         2: split-column
        **      6: json         4: c
        **                      5: json
        **                      6: size
index 02199b5005f7cbe4f968cbdd2351dc7932aedf1c..d7c969c8c41ff28fd6a5709218ed257c27bd8457 100644 (file)
@@ -377,3 +377,32 @@ END
 .check <<END
 .mode psql --rowcount off
 END
+.testcase 910
+.mode psql --reset
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(ab INT, text_column TEXT, int_col INT);
+SELECT * FROM t1;
+.check <<END
+ ab | text_column | int_col
+----+-------------+---------
+(0 rows)
+END
+.testcase 911
+INSERT INTO t1 VALUES(31415926,'Hello',99);
+SELECT * FROM t1;
+.check <<END
+    ab    | text_column | int_col
+----------+-------------+---------
+ 31415926 | Hello       |      99
+(1 row)
+END
+.testcase 912
+INSERT INTO t1 VALUES(2,NULL,2);
+SELECT * FROM t1;
+.check <<END
+    ab    | text_column | int_col
+----------+-------------+---------
+ 31415926 | Hello       |      99
+        2 |             |       2
+(2 rows)
+END
index d3f1580a4dce3a5a406485d26122ba501e87b030..f98f02490fcb30dd35177b467786b1a169d6e5fa 100644 (file)
@@ -100,14 +100,14 @@ do_test 1.11.8 {
 } {
 ╭───┬───┬───╮
 │ a │ b │ c │
\95°â\94\80â\94\80â\94\80â\94´â\94\80â\94\80â\94\80â\94´â\94\80â\94\80â\94\80â\95¯
\95\98â\95\90â\95\90â\95\90â\95§â\95\90â\95\90â\95\90â\95§â\95\90â\95\90â\95\90â\95\9b
 }
 do_test 1.11.9 {
   set result "\n[db format -title always -rowcount on {SELECT * FROM t1 WHERE a=2}]"
 } {
 ╭───┬───┬───╮
 │ a │ b │ c │
\95°â\94\80â\94\80â\94\80â\94´â\94\80â\94\80â\94\80â\94´â\94\80â\94\80â\94\80â\95¯
\95\98â\95\90â\95\90â\95\90â\95§â\95\90â\95\90â\95\90â\95§â\95\90â\95\90â\95\90â\95\9b
 (0 rows)
 }
 
@@ -243,7 +243,7 @@ do_test 1.34.1 {
                  {SELECT * FROM t1 WHERE a=2}]"
 } {
  a │ b │ c
\94\80â\94\80â\94\80â\94´â\94\80â\94\80â\94\80â\94´â\94\80â\94\80â\94\80
\95\90â\95\90â\95\90â\95§â\95\90â\95\90â\95\90â\95§â\95\90â\95\90â\95\90
 }
 do_test 1.35 {
   set result "\n[db format -style box -border off \
@@ -274,6 +274,7 @@ do_test 1.42 {
   set result "\n[db format -style column -title always {SELECT * FROM t1 WHERE a=2}]"
 } {
 a  b  c
+-  -  -
 }
 
 do_test 1.50 {