Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix json_set() so that it can overwrite a value that was previously overwritten during the same call. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0f16041647993975c316203c7e11f06e |
User & Date: | drh 2015-09-22 00:21:03.350 |
Context
2015-09-22
| ||
01:15 | Futher simplifications to json1.c. Also an obscure bug-fix in the initial output of json_tree() when using a path to an object contained within an array. (check-in: fcb1e327a6 user: drh tags: trunk) | |
00:21 | Fix json_set() so that it can overwrite a value that was previously overwritten during the same call. (check-in: 0f16041647 user: drh tags: trunk) | |
2015-09-21
| ||
23:53 | For MSVC, have the 'sqlite3.c' target depend on 'sqlite3ext.h' as well as other targets may depend on this behavior (e.g. extensions). (check-in: 737ac3faf4 user: mistachkin tags: trunk) | |
Changes
Changes to ext/misc/json1.c.
︙ | ︙ | |||
802 803 804 805 806 807 808 809 810 811 812 813 814 815 | if( aUp==0 ){ pParse->oom = 1; return SQLITE_NOMEM; } jsonParseFillInParentage(pParse, 0, 0); return SQLITE_OK; } /* forward declaration */ static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**); /* ** Search along zPath to find the node specified. Return a pointer ** to that node, or NULL if zPath is malformed or if there is no such | > > > > > > > > > > > > > > | 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | if( aUp==0 ){ pParse->oom = 1; return SQLITE_NOMEM; } jsonParseFillInParentage(pParse, 0, 0); return SQLITE_OK; } /* ** Compare the OBJECT label at pNode against zKey,nKey. Return true on ** a match. */ static int jsonLabelCompare(JsonNode *pNode, const char *zKey, int nKey){ if( pNode->jnFlags & JNODE_RAW ){ if( pNode->n!=nKey ) return 0; return strncmp(pNode->u.zJContent, zKey, nKey)==0; }else{ if( pNode->n!=nKey+2 ) return 0; return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; } } /* forward declaration */ static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**); /* ** Search along zPath to find the node specified. Return a pointer ** to that node, or NULL if zPath is malformed or if there is no such |
︙ | ︙ | |||
851 852 853 854 855 856 857 | if( nKey==0 ){ *pzErr = zPath; return 0; } j = 1; for(;;){ while( j<=pRoot->n ){ | | < < | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | if( nKey==0 ){ *pzErr = zPath; return 0; } j = 1; for(;;){ while( j<=pRoot->n ){ if( jsonLabelCompare(pRoot+j, zKey, nKey) ){ return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr); } j++; j += jsonNodeSize(&pRoot[j]); } if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; iRoot += pRoot->u.iAppend; |
︙ | ︙ |
Changes to test/json101.test.
︙ | ︙ | |||
70 71 72 73 74 75 76 77 78 79 80 81 82 83 | } {{{"a":[3,4,5],"b":2}}} do_execsql_test json1-3.3 { SELECT json_type(json_set('{"a":1,"b":2}','$.b','{"x":3,"y":4}'),'$.b'); } {text} do_execsql_test json1-3.4 { SELECT json_type(json_set('{"a":1,"b":2}','$.b',json('{"x":3,"y":4}')),'$.b'); } {object} # Per rfc7159, any JSON value is allowed at the top level, and whitespace # is permitting before and/or after that value. # do_execsql_test json1-4.1 { CREATE TABLE j1(x); INSERT INTO j1(x) | > > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | } {{{"a":[3,4,5],"b":2}}} do_execsql_test json1-3.3 { SELECT json_type(json_set('{"a":1,"b":2}','$.b','{"x":3,"y":4}'),'$.b'); } {text} do_execsql_test json1-3.4 { SELECT json_type(json_set('{"a":1,"b":2}','$.b',json('{"x":3,"y":4}')),'$.b'); } {object} do_execsql_test json1-3.5 { SELECT fullkey, atom, '|' FROM json_tree(json_set('{}','$.x',123,'$.x',456)); } {{$} {} | {$.x} 456 |} # Per rfc7159, any JSON value is allowed at the top level, and whitespace # is permitting before and/or after that value. # do_execsql_test json1-4.1 { CREATE TABLE j1(x); INSERT INTO j1(x) |
︙ | ︙ |