Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.0
-
None
-
None
Description
The help text gives JSON_MERGE_PATCH and JSON_MERGE_PRESERVE the same
sentence, word for word: *"Merges the given JSON documents, returning
the merged result, or NULL if any argument is NULL."* The two functions
do the opposite of each other.
SELECT JSON_MERGE_PATCH(NULL,'[1,2]') AS patch; |
patch
|
[1, 2]
|
|
|
SELECT JSON_MERGE_PRESERVE(NULL,'[1,2]') AS preserve; |
preserve
|
NULL
|
How to repeat
SELECT JSON_MERGE_PATCH(NULL,'[1,2]') AS v; -- [1, 2] |
SELECT JSON_MERGE_PATCH(NULL,'1') AS v; -- 1 |
SELECT JSON_MERGE_PATCH(NULL,'"x"') AS v; -- "x" |
SELECT JSON_MERGE_PATCH(NULL,'true') AS v; -- true |
SELECT JSON_MERGE_PATCH('{"a":1}',NULL,'[3,4]') AS v; -- [3, 4] |
|
|
SELECT JSON_MERGE_PRESERVE(NULL,'[1,2]') AS v; -- NULL |
Which one is wrong
Treating a NULL argument as contributing nothing is RFC 7396 behaviour
and is probably what JSON_MERGE_PATCH should do. If so the defect is in
the help text, which was copied from the preserving form and describes
that form's behaviour.
Either way the two cannot both be right, and the sentence a user reads
before choosing between the functions is the one that is wrong.
Contract: `scripts/fill_help_tables.sql:448` (topic 374,
JSON_MERGE_PATCH) and `:449` (topic 375, JSON_MERGE_PRESERVE).
Affected versions
JSON_MERGE_PATCH was added in 10.2.25.
Verified on 10.11 only (10.11.19-MariaDB-debug, commit 1dab253482d).
Other branches were not tested.
Note
Found while auditing the JSON functions against their documented
contracts. The behaviour is pinned, not the sentence:
func_json.result:914-916 records JSON_MERGE_PATCH(NULL, '[1,2,3]') ->
[1, 2, 3].
Attachments
Issue Links
- split from
-
MDEV-40642 Project "JSON Phoenix" (placeholder)
-
- Open
-