Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.0
-
None
Description
This is a documentation defect, not a code defect. The behaviour is
the MySQL-compatible one and is what the test suite pins; four help rows
describe it wrongly.
SELECT JSON_SET('{}', '$.a', NULL) AS s, |
JSON_REPLACE('{"a":1}', '$.a', NULL) AS r, |
JSON_ARRAY_APPEND('[1]', '$', NULL) AS a, |
JSON_ARRAY_INSERT('[1]', '$[0]', NULL) AS i; |
s r a i
|
{"a": null} {"a": null} [1, null] [null, 1] |
All four help rows say "or NULL if any of the arguments are NULL". A
NULL in the value position does not make the result NULL; it stores a
JSON null, which is the useful and expected behaviour.
How to repeat
Read the help text beside the behaviour:
SELECT JSON_SET('{"a":1}','$.b',NULL,'$.c',2) AS v; |
v
|
{"a": 1, "b": null, "c": 2} |
The wording that is right
JSON_INSERT's row (topic 368) is accurate and is the model the other
four should follow: *"returning the resulting document or NULL if either
of the json_doc or path arguments are null"*.
The four rows to correct are topics 356 (JSON_ARRAY_APPEND), 357
(JSON_ARRAY_INSERT), 386 (JSON_SET) and 389 (JSON_REPLACE), in
`scripts/fill_help_tables.sql`.
Affected versions
The four help rows have carried this wording since the functions
were documented.
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 code behaviour is pinned and correct -
func_json_invalid.result:360-362 records
JSON_SET('
', '$.a', NULL) ->
{"a": null}.
Attachments
Issue Links
- split from
-
MDEV-40642 Project "JSON Phoenix" (placeholder)
-
- Open
-