[MDEV-27972] Unexpected behavior with negative zero (-0) in JSON Path Created: 2022-03-01  Updated: 2022-04-13  Resolved: 2022-03-01

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.9
Fix Version/s: 10.9.0

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

Issue Links:
Relates
relates to MDEV-22224 Support JSON Path negative index Closed

 Description   

Test:

SET @json='{ "x": [0,1]}';
SELECT JSON_VALUE(@json,'$.x[last]');
SELECT JSON_VALUE(@json,'$.x[last-0]');
SELECT JSON_VALUE(@json,'$.x[-0]');
SELECT JSON_VALUE(@json,'$.x[0]');

Expected result:
Expected that 'last' and 'last-0' give the same result

SELECT JSON_VALUE(@json,'$.x[last]');
JSON_VALUE(@json,'$.x[last]')
1
SELECT JSON_VALUE(@json,'$.x[last-0]');
JSON_VALUE(@json,'$.x[last-0]')
1

and index '0' and '-0' too:

SELECT JSON_VALUE(@json,'$.x[-0]');
JSON_VALUE(@json,'$.x[-0]')
0
SELECT JSON_VALUE(@json,'$.x[0]');
JSON_VALUE(@json,'$.x[0]')
0

but Actual result:

SET @json='{ "x": [0,1]}';
SELECT JSON_VALUE(@json,'$.x[last]');
JSON_VALUE(@json,'$.x[last]')
1
SELECT JSON_VALUE(@json,'$.x[last-0]');
JSON_VALUE(@json,'$.x[last-0]')
NULL
SELECT JSON_VALUE(@json,'$.x[-0]');
JSON_VALUE(@json,'$.x[-0]')
NULL
SELECT JSON_VALUE(@json,'$.x[0]');
JSON_VALUE(@json,'$.x[0]')
0



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

patch: https://github.com/MariaDB/server/commit/95fa5ce939813ae91392c597cee0b1cf51757b2b

Comment by Alexey Botchkov [ 2022-03-01 ]

ok to push,

Comment by Rucha Deodhar [ 2022-03-01 ]

rebased on top of bb-10.9-MDEV-22224 and preview-10.9-MDEV-22224

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