[MDEV-27488] Make JSON_EXTRACT validate non-existing keys Created: 2022-01-13  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: JSON, Server
Fix Version/s: 10.11

Type: Task Priority: Major
Reporter: Anel Husakovic Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None


 Description   

MariaDB [(none)]> select json_extract(json_object("key1","val1", "key2", "val2"), '$.key1','$.x','$.key2');
+-----------------------------------------------------------------------------------+
| json_extract(json_object("key1","val1", "key2", "val2"), '$.key1','$.x','$.key2') |
+-----------------------------------------------------------------------------------+
| ["val1", "val2"]                                                                  |
+-----------------------------------------------------------------------------------+
1 row in set (0.000 sec)

If we don't know the path arguments are valid or not we can not say to what arguments result of above query corresponds to key1 or key2 or key1 or x , or any of 8 combination.

If there is a chance to generate NULL as a result per index in path argument, that would be great.



 Comments   
Comment by Weijun Huang [ 2023-02-15 ]

In MySQL 8.0, the result is the same as what MariaDB does now. So your advice is to output

["val1",NULL, "val2"] 

, right? If so, I could try to take it.

Comment by Anel Husakovic [ 2023-02-17 ]

Yes

Comment by Sergei Golubchik [ 2023-02-17 ]

json_extract is non standard, it was added for MySQL compatibility. I suppose it must behave as in MySQL.

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