1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Allow json_replace() to accept JSONB arguments as the new value.

FossilOrigin-Name: 95eb7b37fab29931924311f541d52173ef77a448efc8771b1a1783ccd786d23d
This commit is contained in:
drh
2023-10-02 13:35:06 +00:00
parent 8eeafb7544
commit c97407fdba
4 changed files with 25 additions and 12 deletions

View File

@@ -4620,7 +4620,10 @@ static void jsonReplaceNode(
k = jsonParseAddNode(p, JSON_STRING, n, zCopy);
assert( k>0 || p->oom );
if( p->oom==0 ) p->aNode[k].jnFlags |= JNODE_RAW;
}else{
break;
}
replace_with_json:
{
JsonParse *pPatch = jsonParseCached(pCtx, pValue, pCtx, 1);
if( pPatch==0 ){
p->oom = 1;
@@ -4637,9 +4640,13 @@ static void jsonReplaceNode(
break;
}
default: {
jsonParseAddNode(p, JSON_NULL, 0, 0);
sqlite3_result_error(pCtx, "JSON cannot hold BLOB values", -1);
p->nErr++;
if( jsonFuncArgMightBeBinary(pValue) ){
goto replace_with_json;
}else{
jsonParseAddNode(p, JSON_NULL, 0, 0);
sqlite3_result_error(pCtx, "JSON cannot hold BLOB values", -1);
p->nErr++;
}
break;
}
}