Skip to content

Add support for MSSQL's JSON_ARRAY/JSON_OBJECT expr #1507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Nov 18, 2024

Conversation

gaoqiangz
Copy link
Contributor

Solves #1506

gaoqiangz and others added 4 commits November 10, 2024 00:34
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
@gaoqiangz
Copy link
Contributor Author

gaoqiangz commented Nov 10, 2024

I modified existing Function parsing,include a break change because JSON_OBJECT support FUNC(<expr> : <expr>) syntax:

DECLARE @id_key nvarchar(10) = N'id',@id_value nvarchar(64) = NEWID();
SELECT JSON_OBJECT(LOWER('USER_NAME') : USER_NAME(), LOWER(@id_key) : @id_value, 'sid':(SELECT @@SPID));

Break change:

pub enum FunctionArg {
    Named {
        name: Expr, // <<
        arg: FunctionArgExpr,
        operator: FunctionArgOperator,
    },
    Unnamed(FunctionArgExpr),
}

Please take a look!

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gaoqiangz I think this is looking good! Left some comments

@gaoqiangz
Copy link
Contributor Author

I refactored function parameter list parsing,add some supports_named_fn_args_with_xxx functions to the Dialect trait,please take a look!

gaoqiangz and others added 5 commits November 14, 2024 15:20
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! cc @alamb

@alamb alamb merged commit 92be237 into apache:main Nov 18, 2024
8 checks passed
@alamb
Copy link
Contributor

alamb commented Nov 18, 2024

Thanks again @gaoqiangz and @iffyio and @lovasoa

lovasoa added a commit to lovasoa/sqlparser-rs that referenced this pull request Nov 24, 2024
This just updates the postgres dialect definition to add support for the json_object syntax added in apache#1507

The syntax was initially added for mssql but also works in postgres

See https://www.postgresql.org/docs/current/functions-json.html

See apache#1545
@lovasoa
Copy link
Contributor

lovasoa commented Nov 24, 2024

I opened a new PR to enable this syntax in postgres, which supports it too: #1546

https://www.postgresql.org/docs/current/functions-json.html

@gaoqiangz gaoqiangz deleted the support_mssql_json_object branch November 25, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants