Skip to content

Possible syntax mismatch for json_object in MySQL compatibility mode #3575

@bazoocaze

Description

@bazoocaze

Hello,

I'm using H2 for integration tests on a daily basis, and I think I found a syntax mismatch in MySQL compatibility mode (MODE=MySQL) for the json_object function.

MySQL version: 5.7 and 8.0
H2 version: 2.1.210 and 2.1.214

Exemple 1:

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

MySQL Result: {"last_name": "Doe", "first_name": "John"}
H2 Result: not works (Syntax error in SQL statement)

Exemple 2:

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

MySQL Result: not works (bad SQL grammar)
H2 Result: {"first_name":"John","last_name":"Doe"}

Exemple 3:

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

MySQL Result: not works (bad SQL grammar)
H2 Result: {"first_name":"John","last_name":"Doe"}

https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html#function_json-object

Is it possible (or is it intended to) to have a compatible json_object syntaxe for MySQL compatibility mode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions