Skip to content

JSON_OBJECT does not parse inside RETURN statement #181

@naveennaik1

Description

@naveennaik1

Version - 170.128.0

Parser - TSql170Parser

JSON_OBJECT when inside RETURN statement does not get parsed with above mentioned parser version and details.

Steps to reproduce -

Try parsing the below SQL script with the parser:

ALTER FUNCTION FnName
    ()
RETURNS NVARCHAR(MAX)
AS
    BEGIN
        RETURN
        JSON_OBJECT('Authorization' : 'Bearer ' + (SELECT Value1
                                                           FROM   dbo.table1
                                                           WHERE  field1 = 'Token'));
    END;
GO

Example -

    static void Main(string[] args)
    {
        var script = "<Example Script>";
 
        var parser = new TSql170Parser(true, 0);
        var fragment = parser.Parse(new StringReader(script), out var parseErrors);
 
        if (parseErrors.Count > 0)
        {
            Console.WriteLine(parseErrors[0].Message);
        }
    }

Error message :-

Incorrect syntax near 'JSON_OBJECT'.

This issue is created as a part of follow-up for #137 since it was closed without a fix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions