SqlScriptDOM
SqlScriptDOM copied to clipboard
Add support for `JSON_OBJECTAGG` keyword in TSql170Parser
We have encountered a parsing issue in Microsoft Documentation in JSON_OBJECTAGG using TSql170Parser 170.128.0.
Example script
SELECT JSON_OBJECTAGG( t.c1 : t.c2 )
FROM (
VALUES('key1', 'c'), ('key2', 'b'), ('key3','a')
) AS t(c1, c2);
Steps to reproduce
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 ':'
@naveennaik1 which version of ScriptDom are you using?
@llali I have tried it with v170.128.0 and it gives the same error.
One thing to keep in mind here would be that it only seems to fail when we use an alias before the colon :
Scenario 1
SELECT JSON_OBJECTAGG( t.c1 : t.c2 )
FROM (
VALUES('key1', 'c'), ('key2', 'b'), ('key3','a')
) AS t(c1, c2);
Error Message : Incorrect syntax near ':'
Scenario 2
SELECT JSON_OBJECTAGG( c1 : t.c2 )
FROM (
VALUES('key1', 'c'), ('key2', 'b'), ('key3','a')
) AS t(c1, c2);
Does not throw any error.
fixed in 170.147.0