[MDEV-30634] JSON_INSERT does not return NULL Created: 2023-02-10  Updated: 2023-05-22  Resolved: 2023-05-22

Status: Closed
Project: MariaDB Server
Component/s: Documentation, JSON
Affects Version/s: 10.10.3
Fix Version/s: N/A

Type: Bug Priority: Trivial
Reporter: Sam Mousa Assignee: Ian Gilfillan
Resolution: Fixed Votes: 0
Labels: None

Attachments: PNG File image-2023-02-10-11-54-07-587.png    

 Description   

According to the docs here: https://mariadb.com/kb/en/json_insert/

> Inserts data into a JSON document, returning the resulting document or NULL if any argument is null.

However:

I'm assuming the docs are just worded incorrectly.

Passing 3 arguments of which the 2nd is NULL returns NULL, while consistent with docs this feels weird since other incorrect path strings generate errors

Proposal 1:
Fix docs to say "Inserts data into a JSON document, returning the resulting document or NULL if the json_doc or any path is null.

Proposal 2:
Fix JSON_INSERT and family to never return NULL on invalid arguments. The returning of NULL in cases of bad paths can lead to destructive writes and forces every developer to check these cases.



 Comments   
Comment by Ian Gilfillan [ 2023-04-03 ]

I've updated the docs. I'll leave the issue open for others to decide on the merits of proposal 2.

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