Skip to content
Open
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
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql130.g
Original file line number Diff line number Diff line change
Expand Up @@ -26976,6 +26976,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
{
VerifyColumnDataType(vParent);
}
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql140.g
Original file line number Diff line number Diff line change
Expand Up @@ -27714,6 +27714,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
tHidden:Identifier
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql150.g
Original file line number Diff line number Diff line change
Expand Up @@ -28554,6 +28554,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
tHidden:Identifier
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql160.g
Original file line number Diff line number Diff line change
Expand Up @@ -29034,6 +29034,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
tHidden:Identifier
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql170.g
Original file line number Diff line number Diff line change
Expand Up @@ -29730,6 +29730,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
tHidden:Identifier
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSql180.g
Original file line number Diff line number Diff line change
Expand Up @@ -29968,6 +29968,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
tHidden:Identifier
Expand Down
4 changes: 4 additions & 0 deletions SqlScriptDom/Parser/TSql/TSqlFabricDW.g
Original file line number Diff line number Diff line change
Expand Up @@ -29104,6 +29104,10 @@ regularColumnBody [IndexAffectingStatement statementType, ColumnDefinition vPare
}
)?
)?
(
{NextTokenMatches(CodeGenerationSupporter.Masked) && !vParent.IsMasked}?
maskedClause[vParent]
)?
(
{NextTokenMatches(CodeGenerationSupporter.Hidden)}?
tHidden:Identifier
Expand Down
11 changes: 11 additions & 0 deletions Test/SqlDom/Baselines130/SparseMaskedColumnOrderTests130.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE t (
c VARCHAR (100) SPARSE MASKED WITH (FUNCTION = 'default()') NULL
);

CREATE TABLE t (
c VARCHAR (100) SPARSE MASKED WITH (FUNCTION = 'default()') NULL
);

CREATE TABLE t (
c VARBINARY (MAX) SPARSE FILESTREAM MASKED WITH (FUNCTION = 'default()') NULL
);
1 change: 1 addition & 0 deletions Test/SqlDom/Only130SyntaxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class SqlDomTests
new ParserTest130("ColumnStoreInlineIndex130.sql", 10, 10, 10, 10, 10),
new ParserTest130("CreateIndexStatementTests130.sql", 6, 6, 6, 6, 6),
new ParserTest130("CreateTableTests130.sql", 62, 62, 62, 62, 62),
new ParserTest130("SparseMaskedColumnOrderTests130.sql"),
new ParserTest130("CreateAlterSecurityPolicyStatementTests130.sql", 2, 33, 33, 33, 33),
new ParserTest130("JsonForClauseTests130.sql", 14, 14, 14, 14, 14),
new ParserTest130("DropStatementsTests130.sql", 10, 10, 9, 9, 9),
Expand Down
15 changes: 15 additions & 0 deletions Test/SqlDom/ParserErrorsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ public void CreateTableLedgerGeneratedAlwaysNegativeTest()
new ParserErrorInfo(106, "SQL46010", "HIDEN"));
}

/// <summary>
/// Negative test for GitHub issue #216: MASKED WITH must not be specified twice on the
/// same column, even though SPARSE and MASKED WITH are now accepted in either order.
/// </summary>
[TestMethod]
[Priority(0)]
[SqlStudioTestCategory(Category.UnitTest)]
public void SparseMaskedColumnNegativeTest()
{
string doubleMasked =
"CREATE TABLE t (c VARCHAR(100) MASKED WITH (FUNCTION = 'default()') SPARSE MASKED WITH (FUNCTION = 'email()') NULL)";
ParserTestUtils.ErrorTest140(doubleMasked,
new ParserErrorInfo(doubleMasked.IndexOf("SPARSE MASKED") + 7, "SQL46010", "MASKED"));
}

/// <summary>
/// Negative tests for HIDDEN columns
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions Test/SqlDom/TestScripts/SparseMaskedColumnOrderTests130.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Regression tests for GitHub issue #216: SPARSE combined with MASKED WITH must parse in
-- either clause order. The order documented by the CREATE TABLE reference is SPARSE first,
-- then MASKED WITH.

-- Documented order: SPARSE before MASKED WITH (this is the case that used to fail).
CREATE TABLE t (c VARCHAR(100) SPARSE MASKED WITH (FUNCTION = 'default()') NULL);

-- Reversed order: MASKED WITH before SPARSE (this already worked).
CREATE TABLE t (c VARCHAR(100) MASKED WITH (FUNCTION = 'default()') SPARSE NULL);

-- SPARSE FILESTREAM storage followed by MASKED WITH.
CREATE TABLE t (c VARBINARY(MAX) FILESTREAM SPARSE MASKED WITH (FUNCTION = 'default()') NULL);