[MDEV-19487] JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER" Created: 2019-05-15  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2.22, 10.3.15, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Francisco Dueñas Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Windows 10 64 bit


Issue Links:
PartOf
is part of MDEV-15931 JSON_TYPE doesn't work correctly Stalled

 Description   

Hi this sentence:

select JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date'));

Returns INTEGER, at least it should say 'STRING'

select JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.name'));

returns NULL, if you apply JSON_QUOTE for the JSON_VALUE returned value, it returns STRING.



 Comments   
Comment by Sergei Golubchik [ 2019-05-17 ]

I'd say, both should be NULL. In the first query, JSON_VALUE() returns 2019-01-01 which is not a valid JSON literal, in the second query it returns Monty which is not a valid JSON literal either.

If you'd use JSON_EXTRACT() instead of JSON_VALUE(), it'd return "2019-01-01" and "Monty", both are valid JSON strings.

Generated at Thu Feb 08 08:52:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.