microsoft / SqlScriptDOM

ScriptDOM/SqlDOM is a .NET library for parsing T-SQL statements and interacting with its abstract syntax tree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TSql160Parser fails to parse CREATE USER FROM EXTERNAL PROVIDER WITH OBJECT_ID

holc-tkomp opened this issue · comments

Issue

Microsoft.SqlServer.TransactSql.ScriptDom.TSql160Parser fails to parse following sql:

CREATE USER xxxx FROM EXTERNAL PROVIDER WITH OBJECT_ID='xxx'

WITH OBJECT_ID syntax doesn't seem to be documented yet, however it's already available on (some?) Azure databases, see https://github.com/MicrosoftDocs/sql-docs/issues/7167.

Reproduction

Latest tested version of Microsoft.SqlServer.TransactSql.ScriptDom package: 161.8905.0

using Microsoft.SqlServer.TransactSql.ScriptDom;

var sql = "CREATE USER xxxx FROM EXTERNAL PROVIDER WITH OBJECT_ID='xxx'";
var parser = new TSql160Parser(true);
parser.Parse(new StringReader(sql), out var errors);

if (errors?.Count > 0)
    Console.WriteLine(errors[0].Message); // Expected PASSWORD but encountered OBJECT_ID instead.

@holc-tkomp The syntax is neither released or supported.

Are you considering to add support for this in the future though? Or if we'd want to support this syntax in near future we would have to use a different parser?

@holc-tkomp could you please help us by explaining your broader scenario? Are you trying to do this in the context of a DACPAC deployment as a post-deployment script, or such? Why is it necessary for you to specify the OID using this undocumented syntax?

The script is something used by one of our clients. Our tool (SSMS addin) allows formatting of script within SSMS query window and for that we use your parser, so we can analyze tokens/fragments to decide where to put newlines, semicolons, etc.