/ Check-in [b45b1885]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Correct output for the fullkey column of json_each() when the total JSON input is a simple value, not an array or object.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b45b18850c59f22a163ee482f529f578a8798f96d0e26b5a061d336d480a1540
User & Date: drh 2018-05-16 12:19:11
Context
2018-05-16
15:35
Enhance the sqlite3_str_new() interface so that it always returns a valid and non-NULL pointer even in an OOM condition. check-in: ed5b0968 user: drh tags: trunk
12:19
Correct output for the fullkey column of json_each() when the total JSON input is a simple value, not an array or object. check-in: b45b1885 user: drh tags: trunk
2018-05-15
09:09
Fix a test case problem in wherelimit.test. check-in: 3012df8b user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/json1.c.

  2114   2114           if( p->zRoot ){
  2115   2115             jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));
  2116   2116           }else{
  2117   2117             jsonAppendChar(&x, '$');
  2118   2118           }
  2119   2119           if( p->eType==JSON_ARRAY ){
  2120   2120             jsonPrintf(30, &x, "[%d]", p->iRowid);
  2121         -        }else{
         2121  +        }else if( p->eType==JSON_OBJECT ){
  2122   2122             jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1);
  2123   2123           }
  2124   2124         }
  2125   2125         jsonResult(&x);
  2126   2126         break;
  2127   2127       }
  2128   2128       case JEACH_PATH: {

Changes to test/json101.test.

   779    779                    WHERE Z.value==t2.id);
   780    780   } {1 {{"items":[3,5]}} 3 {{"value":3}} 1 {{"items":[3,5]}} 5 {{"value":5}}}
   781    781   do_execsql_test json-13.110 {
   782    782     SELECT * FROM t2 CROSS JOIN t1
   783    783      WHERE EXISTS(SELECT 1 FROM json_each(t1.json,'$.items') AS Z
   784    784                    WHERE Z.value==t2.id);
   785    785   } {3 {{"value":3}} 1 {{"items":[3,5]}} 5 {{"value":5}} 1 {{"items":[3,5]}}}
          786  +
          787  +# 2018-05-16
          788  +# Incorrect fullkey output from json_each()
          789  +# when the input JSON is not an array or object.
          790  +#
          791  +do_execsql_test json-14.100 {
          792  +  SELECT fullkey FROM json_each('123');
          793  +} {$}
          794  +do_execsql_test json-14.110 {
          795  +  SELECT fullkey FROM json_each('123.56');
          796  +} {$}
          797  +do_execsql_test json-14.120 {
          798  +  SELECT fullkey FROM json_each('"hello"');
          799  +} {$}
          800  +do_execsql_test json-14.130 {
          801  +  SELECT fullkey FROM json_each('null');
          802  +} {$}
          803  +do_execsql_test json-14.140 {
          804  +  SELECT fullkey FROM json_tree('123');
          805  +} {$}
          806  +do_execsql_test json-14.150 {
          807  +  SELECT fullkey FROM json_tree('123.56');
          808  +} {$}
          809  +do_execsql_test json-14.160 {
          810  +  SELECT fullkey FROM json_tree('"hello"');
          811  +} {$}
          812  +do_execsql_test json-14.170 {
          813  +  SELECT fullkey FROM json_tree('null');
          814  +} {$}
          815  +
   786    816   
   787    817   
   788    818   finish_test