/ Check-in [45bfcb88e7]
Login

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

Overview
Comment:Fix a problem with handling with handling quoted path elements in extension functions json_set() and json_insert() reported on the mailing list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 45bfcb88e71451a656982e217375e257fc8e68374349c2984be1266bf86fb8cf
User & Date: dan 2019-06-17 14:50:33
Context
2019-06-21
14:05
Fix a typo in an option name for the .dbconfig command in shell.c.in: s/wriable_schema/writable_schema/ check-in: 1c58522e49 user: dan tags: trunk
2019-06-17
14:50
Fix a problem with handling with handling quoted path elements in extension functions json_set() and json_insert() reported on the mailing list. check-in: 45bfcb88e7 user: dan tags: trunk
14:13
New sqlite3_db_config() options: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, SQLITE_DBCONFIG_DQS_DML, and SQLITE_DBCONFIG_DQS_DDL. check-in: a61db8ff67 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/json1.c.

1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
      pRoot = &pParse->aNode[iRoot];
      j = 1;
    }
    if( pApnd ){
      u32 iStart, iLabel;
      JsonNode *pNode;
      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);
      iLabel = jsonParseAddNode(pParse, JSON_STRING, i, zPath);
      zPath += i;
      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);
      if( pParse->oom ) return 0;
      if( pNode ){
        pRoot = &pParse->aNode[iRoot];
        pRoot->u.iAppend = iStart - iRoot;
        pRoot->jnFlags |= JNODE_APPEND;







|







1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
      pRoot = &pParse->aNode[iRoot];
      j = 1;
    }
    if( pApnd ){
      u32 iStart, iLabel;
      JsonNode *pNode;
      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);
      iLabel = jsonParseAddNode(pParse, JSON_STRING, nKey, zKey);
      zPath += i;
      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);
      if( pParse->oom ) return 0;
      if( pNode ){
        pRoot = &pParse->aNode[iRoot];
        pRoot->u.iAppend = iStart - iRoot;
        pRoot->jnFlags |= JNODE_APPEND;

Changes to test/json104.test.

9
10
11
12
13
14
15

16
17
18
19
20
21
22
...
121
122
123
124
125
126
127

128






















129

130


#
#***********************************************************************
# This file implements tests for json_patch(A,B) SQL function.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl


ifcapable !json1 {
  finish_test
  return
}

# This is the example from pages 2 and 3 of RFC-7396
................................................................................
do_execsql_test json104-313 {
  SELECT json_patch('[1,2]','{"a":"b","c":null}');
} {{{"a":"b"}}}
do_execsql_test json104-314 {
  SELECT json_patch('{}','{"a":{"bb":{"ccc":null}}}');
} {{{"a":{"bb":{}}}}}



























finish_test









>







 







>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>

>
>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#
#***********************************************************************
# This file implements tests for json_patch(A,B) SQL function.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix json104

ifcapable !json1 {
  finish_test
  return
}

# This is the example from pages 2 and 3 of RFC-7396
................................................................................
do_execsql_test json104-313 {
  SELECT json_patch('[1,2]','{"a":"b","c":null}');
} {{{"a":"b"}}}
do_execsql_test json104-314 {
  SELECT json_patch('{}','{"a":{"bb":{"ccc":null}}}');
} {{{"a":{"bb":{}}}}}

#-------------------------------------------------------------------------

do_execsql_test 401 {
  CREATE TABLE obj(x);
  INSERT INTO obj VALUES('{"a":1,"b":2}');
  SELECT * FROM obj;
} {{{"a":1,"b":2}}}
do_execsql_test 402 {
  UPDATE obj SET x = json_insert(x, '$.c', 3);
  SELECT * FROM obj;
} {{{"a":1,"b":2,"c":3}}}
do_execsql_test 403 {
  SELECT json_extract(x, '$.b') FROM obj;
  SELECT json_extract(x, '$."b"') FROM obj;
} {2 2}
do_execsql_test 404 {
  UPDATE obj SET x = json_set(x, '$."b"', 555);
  SELECT json_extract(x, '$.b') FROM obj;
  SELECT json_extract(x, '$."b"') FROM obj;
} {555 555}
do_execsql_test 405 {
  UPDATE obj SET x = json_set(x, '$."d"', 4);
  SELECT json_extract(x, '$."d"') FROM obj;
} {4}


finish_test