Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.9(EOL)
-
None
Description
Test:
SET @json1= '[
|
[{"key1": "value1"}, {"key2": "value2"}],
|
[{"key3": "value3"}, {"key1": "value4"}],
|
[{"key1": "value5"}, {"key4": "value6"}, {"key1": "value7"}]
|
]';
|
SELECT JSON_VALUE(@json1, '$[2][1 to 2].key1');
|
SELECT JSON_VALUE(@json1, '$[2][1].key1');
|
SELECT JSON_VALUE(@json1, '$[2][2].key1');
|
Expected result:
SET @json1= '[
|
[{"key1": "value1"}, {"key2": "value2"}],
|
[{"key3": "value3"}, {"key1": "value4"}],
|
[{"key1": "value5"}, {"key4": "value6"}, {"key1": "value7"}]
|
]';
|
SELECT JSON_VALUE(@json1, '$[2][1 to 2].key1');
|
JSON_VALUE(@json1, '$[2][1 to 2].key1')
|
value7
|
SELECT JSON_VALUE(@json1, '$[2][1].key1');
|
JSON_VALUE(@json1, '$[2][1].key1')
|
NULL
|
SELECT JSON_VALUE(@json1, '$[2][2].key1');
|
JSON_VALUE(@json1, '$[2][2].key1')
|
value7
|
Actual result:
SET @json1= '[
|
[{"key1": "value1"}, {"key2": "value2"}],
|
[{"key3": "value3"}, {"key1": "value4"}],
|
[{"key1": "value5"}, {"key4": "value6"}, {"key1": "value7"}]
|
]';
|
SELECT JSON_VALUE(@json1, '$[2][1 to 2].key1');
|
JSON_VALUE(@json1, '$[2][1 to 2].key1')
|
value5
|
SELECT JSON_VALUE(@json1, '$[2][1].key1');
|
JSON_VALUE(@json1, '$[2][1].key1')
|
NULL
|
SELECT JSON_VALUE(@json1, '$[2][2].key1');
|
JSON_VALUE(@json1, '$[2][2].key1')
|
value7
|
The same behavior when json contains only arrays:
SET @json= '[
|
[1.1, {"key1": "value1"}, 3],
|
[false, 5, 6],
|
[7, 8, [9, {"key2": 2}, 11]],
|
[11, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
|
[19, 20]
|
]';
|
SELECT JSON_VALUE(@json, '$[2 to 3][0]');
|
JSON_VALUE(@json, '$[2 to 3][0]')
|
1.1
|
SELECT JSON_VALUE(@json, '$[2][0]');
|
JSON_VALUE(@json, '$[2][0]')
|
7
|
SELECT JSON_VALUE(@json, '$[3][0]');
|
JSON_VALUE(@json, '$[3][0]')
|
11
|
"1.1" is the first value in array not first in the specified range.
Attachments
Issue Links
- relates to
-
MDEV-27911 Implement range notation for json path
- Closed