Why does Microsoft.SqlServer.TransactSql.ScriptDom.TSqlParser fail to parse a simple valid expression?

538 Views Asked by At

We are using Microsoft.SqlServer.TransactSql.ScriptDom heavily to process some SQL scripts.

Our understanding is that the parser is supposed to be full fidelity.

However, we recently found this bug:

using Microsoft.SqlServer.TransactSql.ScriptDom;

var parser = new TSql150Parser(true);

string expr = @"IIF( (IIF(1 = 1, 1, NULL)) IS NULL, 1, 0)";

var res = parser.ParseExpression(new StringReader(expr), out var errors);

bool isSuccess = errors.Count == 0;

Expected result: isSuccess is true

Actual result: isSuccess is false

Running the following query in SQL server works: SELECT IIF( (IIF(1 = 1, 1, NULL)) IS NULL, 1, 0)

So we would expect the parser to be able to parse it as well.

Is this a known bug?

0

There are 0 best solutions below