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

ScriptDom can't parse CREATE DATABASE ... ELASTIC_POOL

taspeotis opened this issue · comments

ScriptDom doesn't understand SQL Azure Elastic Pools.

  • SqlPackage or DacFx Version: 160.5400.1
  • .NET Framework (Windows-only) or .NET Core: 6.0.101
  • Environment (local platform and source/target platforms): SQL Azure

Steps to Reproduce:

You can take this example CREATE DATABASE statement from the documentation for reproduction:

const string sql = "CREATE DATABASE db1 ( SERVICE_OBJECTIVE = ELASTIC_POOL ( name = S3M100 ) ) ;";
using var stringReader = new StringReader(sql);
var parser = new TSql160Parser(true, SqlEngineType.All);
var fragment = parser.Parse(stringReader, out var errors);

errors now contains one error: Incorrect syntax near ELASTIC_POOL. I tried SqlEngineType.SqlAzure but the result was the same.

SQL Azure parses it:

image

And if I try to execute it, it runs.

DacFx does not support elastic pools, as mentioned in the limitations for bacpacs. The workaround is to create a single database for DacFx operations, then move the database into an elastic pool.

Thanks for the reply.

Are ScriptDom and BACPACs intertwined? Because I am trying to parse Transact-SQL, not do anything with a BACPAC. I was under the impression ScriptDom stood apart from DacFx things.

If ScriptDom exists exclusively for BACPACs then I can understand this is not a bug and rather a feature request.

@taspeotis - ScriptDom is not exclusively for BACPAC operations. Conceptually, we should be supporting this syntax in ScriptDom.

CC: @yualan @dzsquared