1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-22976 CAST(JSON_EXTRACT() AS DECIMAL) does not handle boolean values

Item_func_json_extract did not implement val_decimal(),
so CAST(JSON_EXTRACT('{"x":true}', '$.x') AS DECIMAL) erroneously
returned 0 with a warning because of convertion from the string "true"
to decimal.

Implementing val_decimal(), so boolean values are correctly handled.
This commit is contained in:
Alexander Barkov
2020-06-22 15:43:53 +04:00
parent 009ef36d9a
commit 30903c3743
4 changed files with 62 additions and 0 deletions

View File

@ -916,5 +916,18 @@ NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 2 to function 'json_merge_patch'
#
# MDEV-22976 CAST(JSON_EXTRACT() AS DECIMAL) does not handle boolean values
#
SELECT
CAST(JSON_EXTRACT('{"x":true}', '$.x') AS DOUBLE) AS cf,
CAST(JSON_EXTRACT('{"x":true}', '$.x') AS DECIMAL) AS cd;
cf cd
1 1
SELECT
CAST(JSON_EXTRACT('{"x":false}', '$.x') AS DOUBLE) AS cf,
CAST(JSON_EXTRACT('{"x":false}', '$.x') AS DECIMAL) AS cd;
cf cd
0 0
#
# End of 10.2 tests
#