[MDEV-28071] JSON_EXISTS returns always 1 if it is used range notation for json path Created: 2022-03-15  Updated: 2022-04-14  Resolved: 2022-04-12

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: None
Fix Version/s: 10.9.1

Type: Bug Priority: Major
Reporter: Lena Startseva Assignee: Rucha Deodhar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-27911 Implement range notation for json path Closed

 Description   

Test: (value in range 3 to 4 is absent)

SET @json= '[
             [1, {"key1": "value1"}, 3],
             [false, 5, 6],
             [7, 8, [9, {"key2": 2}, 11]],
             [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
             [19, 20],
             21, 22
            ]';
SELECT JSON_EXISTS(@json, '$[2][2][3]');
SELECT JSON_EXISTS(@json, '$[2][2][4]');
SELECT JSON_EXISTS(@json, '$[2][2][3 to 4]');

Expected result:

SET @json= '[
             [1, {"key1": "value1"}, 3],
             [false, 5, 6],
             [7, 8, [9, {"key2": 2}, 11]],
             [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
             [19, 20],
             21, 22
            ]';
SELECT JSON_EXISTS(@json, '$[2][2][3]');
JSON_EXISTS(@json, '$[2][2][3]')
0
SELECT JSON_EXISTS(@json, '$[2][2][4]');
JSON_EXISTS(@json, '$[2][2][4]')
0
SELECT JSON_EXISTS(@json, '$[2][2][3 to 4]');
JSON_EXISTS(@json, '$[2][2][3 to 4]')
0

Actual result:

SET @json= '[
             [1, {"key1": "value1"}, 3],
             [false, 5, 6],
             [7, 8, [9, {"key2": 2}, 11]],
             [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
             [19, 20],
             21, 22
            ]';
SELECT JSON_EXISTS(@json, '$[2][2][3]');
JSON_EXISTS(@json, '$[2][2][3]')
0
SELECT JSON_EXISTS(@json, '$[2][2][4]');
JSON_EXISTS(@json, '$[2][2][4]')
0
SELECT JSON_EXISTS(@json, '$[2][2][3 to 4]');
JSON_EXISTS(@json, '$[2][2][3 to 4]')
1



 Comments   
Comment by Rucha Deodhar [ 2022-03-21 ]

Patch: https://github.com/MariaDB/server/commit/c66ce14fca08999d18f2db09097631591d3b12cb

Comment by Alexey Botchkov [ 2022-04-12 ]

ok to push.

Comment by Rucha Deodhar [ 2022-04-12 ]

Pushed to https://github.com/MariaDB/server/tree/bb-10.9-MDEV-27911

Generated at Thu Feb 08 09:57:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.