sqlite/test/json104.test
drh f07b249f92 Change the name of the new function to "json_merge_patch()".
FossilOrigin-Name: 53bf70f37bbca319ea35f70849e2a34ae628a504486158fdad5c4bb7431c68e0
2017-03-22 21:45:20 +00:00

60 lines
1.4 KiB
Plaintext

# 2017-03-22
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements tests for json_mergepatch(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-100 {
SELECT json_merge_patch('{
"a": "b",
"c": {
"d": "e",
"f": "g"
}
}','{
"a":"z",
"c": {
"f": null
}
}');
} {{{"a":"z","c":{"d":"e"}}}}
# This is the example from pages 4 and 5 of RFC-7396
do_execsql_test json104-110 {
SELECT json_merge_patch('{
"title": "Goodbye!",
"author" : {
"givenName" : "John",
"familyName" : "Doe"
},
"tags":[ "example", "sample" ],
"content": "This will be unchanged"
}','{
"title": "Hello!",
"phoneNumber": "+01-123-456-7890",
"author": {
"familyName": null
},
"tags": [ "example" ]
}');
} {{{"title":"Hello!","author":{"givenName":"John"},"tags":["example"],"content":"This will be unchanged",phoneNumber:"+01-123-456-7890"}}}
finish_test