Visitar URL original
Sync Repos: Release 180.102.0 by allancascante · Pull Request #230 · microsoft/SqlScriptDOM · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SqlScriptDom/Parser/TSql/Ast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3550,6 +3550,8 @@
</Class>
<Class Name="OrderByClause" Summary="Represents the order by clause that can be used in statements like select.">
<Member Name="OrderByElements" Type="ExpressionWithSortOrder" Collection="true" Summary="The items."/>
<Member Name="All" Type="bool" Summary="True if the ORDER BY ALL shorthand is used, which orders by every column in the select list. When true, OrderByElements is empty."/>
<Member Name="AllSortOrder" Type="SortOrder" GenerateUpdatePositionInfoCall="false" Summary="The sort order (ASC/DESC) applied to ORDER BY ALL. Only meaningful when All is true."/>
</Class>
<Class Name="JoinTableReference" Base="TableReference" Abstract="true" Summary="Base class for JOIN table references">
<Member Name="FirstTableReference" Type="TableReference" Summary="The first table reference."/>
Expand Down Expand Up @@ -4046,6 +4048,7 @@
</Class>
<Class Name="TSqlScript" Summary="Represents a TSql sript.">
<Member Name="Batches" Type="TSqlBatch" Collection ="true" Summary="Batches in the script."/>
<Member Name="TrailingGoCount" Type="int" Summary="The number of consecutive trailing GO batch separators at the end of the script (0 if none)."/>
</Class>
<Class Name="TSqlBatch" Summary="Represents a batch in T-SQL script." >
<Member Name="Statements" Type="TSqlStatement" Collection="true" Summary="A list of statements, possibly empty."/>
Expand Down
20 changes: 20 additions & 0 deletions SqlScriptDom/Parser/TSql/OptionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public OptionType Value
{
get { return _optionValue; }
}

public string Identifier
{
get { return _identifier; }
}
}

private Dictionary<OptionType, OptionInfo> _optionToOptionInfo = new Dictionary<OptionType, OptionInfo>();
Expand Down Expand Up @@ -208,6 +213,21 @@ internal bool TryGenerateSourceForOption(ScriptWriter writer, OptionType option)
return false;
}

// Exposes the literal source text of identifier-backed options so callers can apply their own
// casing; returns false for token-backed options, whose text comes from the token table.
internal bool TryGetOptionIdentifier(OptionType option, out string identifier)
{
OptionInfo optionInfo;
if (_optionToOptionInfo.TryGetValue(option, out optionInfo) && optionInfo.Identifier != null)
{
identifier = optionInfo.Identifier;
return true;
}

identifier = null;
return false;
}

internal void GenerateCommaSeparatedFlagOptions(ScriptWriter writer, OptionType options)
{
bool first = true;
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql100.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down
8 changes: 8 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql110.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -2677,6 +2681,10 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
vResult.DatabaseName = vIdentifier;
ThrowPartialAstIfPhaseOne(vResult);
}
// NOTE: Unlike TSql120+, azureOptions and the collationOpt branch here are mutually-exclusive
// alternatives, so COLLATE and Azure edition options cannot coexist in either order. The
// COLLATE-before-options fix applied to TSql120-180/FabricDW is intentionally NOT ported here:
// it would require restructuring these alternatives into sequential optionals (a larger change).
(
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2)}?
azureOptions[vResult, vResult.Options]
Expand Down
11 changes: 11 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql120.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -2771,6 +2775,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down
16 changes: 16 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql130.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -3530,6 +3534,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down Expand Up @@ -26975,6 +26986,11 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
vParent.StorageOptions = vStorageOptions;
}
)?
// MASKED WITH may follow the storage options (documented SPARSE-before-MASKED order)
(
{NextTokenMatches(CodeGenerationSupporter.Masked)}?
maskedClause[vParent]
)?
)?
{
VerifyColumnDataType(vParent);
Expand Down
16 changes: 16 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql140.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -3904,6 +3908,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down Expand Up @@ -27713,6 +27724,11 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
vParent.StorageOptions = vStorageOptions;
}
)?
// MASKED WITH may follow the storage options (documented SPARSE-before-MASKED order)
(
{NextTokenMatches(CodeGenerationSupporter.Masked)}?
maskedClause[vParent]
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
Expand Down
16 changes: 16 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql150.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -4427,6 +4431,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down Expand Up @@ -28553,6 +28564,11 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
vParent.StorageOptions = vStorageOptions;
}
)?
// MASKED WITH may follow the storage options (documented SPARSE-before-MASKED order)
(
{NextTokenMatches(CodeGenerationSupporter.Masked)}?
maskedClause[vParent]
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
Expand Down
16 changes: 16 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql160.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -4447,6 +4451,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down Expand Up @@ -29033,6 +29044,11 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
vParent.StorageOptions = vStorageOptions;
}
)?
// MASKED WITH may follow the storage options (documented SPARSE-before-MASKED order)
(
{NextTokenMatches(CodeGenerationSupporter.Masked)}?
maskedClause[vParent]
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
Expand Down
16 changes: 16 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql170.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -4496,6 +4500,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down Expand Up @@ -29729,6 +29740,11 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
vParent.StorageOptions = vStorageOptions;
}
)?
// MASKED WITH may follow the storage options (documented SPARSE-before-MASKED order)
(
{NextTokenMatches(CodeGenerationSupporter.Masked)}?
maskedClause[vParent]
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
Expand Down
16 changes: 16 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql180.g
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ script returns [TSqlScript vResult = this.FragmentFactory.CreateFragment<TSqlScr
(
Go
{
vResult.TrailingGoCount++;
ResetQuotedIdentifiersSettingToInitial();
ThrowPartialAstIfPhaseOne(null);
}
vCurrentBatch = batch
{
if (vCurrentBatch != null)
{
AddAndUpdateTokenInfo(vResult, vResult.Batches, vCurrentBatch);
vResult.TrailingGoCount = 0;
}
}

)*
Expand Down Expand Up @@ -4499,6 +4503,13 @@ createDatabase returns [CreateDatabaseStatement vResult = FragmentFactory.Create
)?
recoveryUnitList[vResult]
collationOpt[vResult]
(
// Azure SQL: parenthesized edition options may follow COLLATE.
// Limitation: each azureOptions invocation checks SQL46049 duplicates only within its own
// group, so an option repeated across the pre- and post-COLLATE groups is not flagged.
{NextTokenMatches(CodeGenerationSupporter.MaxSize,2) || NextTokenMatches(CodeGenerationSupporter.Edition,2) || NextTokenMatches(CodeGenerationSupporter.ServiceObjective,2)}?
azureOptions[vResult, vResult.Options]
)?
(
dbAddendums[vResult]
)?
Expand Down Expand Up @@ -29967,6 +29978,11 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
vParent.StorageOptions = vStorageOptions;
}
)?
// MASKED WITH may follow the storage options (documented SPARSE-before-MASKED order)
(
{NextTokenMatches(CodeGenerationSupporter.Masked)}?
maskedClause[vParent]
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
Expand Down
Loading
Loading