Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1
Description
For a non-array document, the same server treats '$[0]' and '$[last]' inconsistently.
Reproduced on 10.11.19 (debug build):
-- '$[0]': the document is auto-wrapped, consistently
|
SELECT JSON_EXISTS('{"a":1}', '$[0]'), -- 1 |
JSON_SET('{"a":1}', '$[0]', 9), -- 9 |
JSON_INSERT('{"a":1}', '$[0]', 9); -- {"a": 1} (path exists: no-op) |
|
|
-- '$[last]' on the same document
|
SELECT JSON_EXISTS('{"a":1}', '$[last]'), -- 0 |
JSON_SET('{"a":1}', '$[last]', 9), -- 9 (whole document replaced) |
JSON_INSERT('{"a":1}', '$[last]', 9), -- [{"a": 1}, 9] |
JSON_REPLACE('{"a":1}', '$[last]', 9), -- {"a": 1} |
JSON_EXTRACT('{"a":1}', '$[last]'); -- NULL ('$[0]' returns the document) |
JSON_EXISTS = 0 means the path does not exist, so by the documented relation between the edit functions JSON_SET should behave like JSON_INSERT ([
{"a": 1}, 9]). Instead it silently replaces the whole document with the value — data loss. On the read side the two index spellings also disagree with each other.
Attachments
Issue Links
- relates to
-
MDEV-22224 Support JSON Path negative index
-
- Closed
-