mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-32007: JSON_VALUE and JSON_EXTRACT doesn't handle dash (-)
as first character in key Analysis: While parsing the path, if '-' is encountered as a part of the key, the state of the parser changes to error. Hence NULL is returned eventually. Fix: If '-' encountered as part of the key, change the state appropriately to continue scanning the key.
This commit is contained in:
@@ -2608,3 +2608,24 @@ SET @@collation_connection= @save_collation_connection;
|
||||
#
|
||||
# End of 10.9 Test
|
||||
#
|
||||
#
|
||||
# MDEV-32007: JSON_VALUE and JSON_EXTRACT doesn't handle dash (-)
|
||||
# as first character in key
|
||||
#
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS jsonTest AS
|
||||
SELECT '{ "-1234" : "something",
|
||||
"12-34" : "else",
|
||||
"1234-" : "and",
|
||||
"1234" : "match" }' AS 'message';
|
||||
SELECT JSON_SEARCH(message, 'one', 'something') AS t1_path,
|
||||
JSON_VALUE(message, JSON_UNQUOTE(JSON_SEARCH(message, 'one', 'something'))) AS t1_result,
|
||||
JSON_SEARCH(message, 'one', 'else') AS t2_path,
|
||||
JSON_VALUE(message, JSON_UNQUOTE(JSON_SEARCH(message, 'one', 'else'))) AS t2_result,
|
||||
JSON_SEARCH(message, 'one', 'and') AS t3_path,
|
||||
JSON_VALUE(message, JSON_UNQUOTE(JSON_SEARCH(message, 'one', 'and'))) AS t3_result,
|
||||
JSON_SEARCH(message, 'one', 'match') AS t4_path,
|
||||
JSON_VALUE(message, JSON_UNQUOTE(JSON_SEARCH(message, 'one', 'match'))) AS t4_result
|
||||
FROM jsonTest;
|
||||
t1_path t1_result t2_path t2_result t3_path t3_result t4_path t4_result
|
||||
"$.-1234" something "$.12-34" else "$.1234-" and "$.1234" match
|
||||
# End of 11.0 test
|
||||
|
Reference in New Issue
Block a user