0

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?

Clement
  • 3,990
  • 4
  • 43
  • 44
  • 1) Have you tried adding ELECT to the statement before sending it to the parser, does that change anything? 2) What is the value of errors.count if not 0? 3) Have you looked at the errors returns? 3.1) If not, why not? 3.2) If so, what are the error messages sent back? – TechGnome Sep 27 '19 at 11:54
  • SELECT is not required because I use .ParseExpression and not .Parse. – Clement Sep 27 '19 at 13:00
  • There is a single error "Incorrect syntax near )." – Clement Sep 27 '19 at 13:01
  • Pretty sure it's a bug. Consider upvoting here: https://feedback.azure.com/forums/908035-sql-server/suggestions/38694355-microsoft-sqlserver-transactsql-scriptdom-tsqlpars – Clement Sep 27 '19 at 13:02

0 Answers0