[MDEV-29161] Non-standard syntaxe for JSON_OBJECT function Created: 2022-07-24  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Minor
Reporter: Jose F Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Linux Mint 20.3 (Una)
Docker 20.10.12



 Description   

MariaDB has a non-standard syntaxe for JSON_OBJECT, and also does not accept the standard syntaxe (as defined in ISO/IEC 9075:2016):

Example 1:

select json_object('first_name', 'John', 'last_name', 'Doe');

MariaDB Result:

{"last_name": "Doe", "first_name": "John"}

MySQL Result:

{"last_name": "Doe", "first_name": "John"}

Example 2:

select json_object('first_name': 'John', 'last_name': 'Doe');

MariaDB Result: not works (You have an error in your SQL syntax)
MySQL Result: not works (bad SQL grammar)

  1. Example 3:

select json_object(key 'first_name' value 'John', key 'last_name' value 'Doe');

MariaDB Result: not works (You have an error in your SQL syntax)
MySQL Result: not works (bad SQL grammar)

It would be nice to have MariaDB support the standard json_object syntaxe.

https://github.com/h2database/h2database/issues/3575
https://en.wikipedia.org/wiki/SQL:2016
https://www.iso.org/standard/78937.html?browse=tc



 Comments   
Comment by Sergei Golubchik [ 2022-07-24 ]

you and H2 guys are right, the standard syntax is with a colon ':', not with a comma ','. I agree that we should support the standard syntax. As for key/value variant — I wasn't able to find it in the standard. Can you point out where the 2016 standard says that? Part, section, subsection, etc?

Comment by Jose F [ 2022-07-25 ]

Hi,
I don't have access to the full standart, but the guys at H2 answered the question here https://github.com/h2database/h2database/pull/3579#issuecomment-1193434520
It's seems that key/value variant is part of the standard, too.

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