Skip to content

Commit 90804f3

Browse files
committed
Bug fix in SQL data masking when updating rule
1 parent ea96a7f commit 90804f3

File tree

6 files changed

+4326
-2682
lines changed

6 files changed

+4326
-2682
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests/TestDatabaseDataMaskingBasicRuleLifecycle.json

Lines changed: 574 additions & 574 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests/TestDatabaseDataMaskingNumberRuleLifecycle.json

Lines changed: 1790 additions & 542 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests/TestDatabaseDataMaskingRuleCreationFailures.json

Lines changed: 599 additions & 503 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests/TestDatabaseDataMaskingRuleCreationWithoutPolicy.json

Lines changed: 770 additions & 482 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DataMaskingTests/TestDatabaseDataMaskingTextRuleLifecycle.json

Lines changed: 578 additions & 578 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql/Data Masking/Cmdlet/BuildAzureSqlDatabaseDataMaskingRule.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,21 @@ protected string ValidateRuleTarget(IEnumerable<DatabaseDataMaskingRuleModel> ru
127127
/// <returns>An updated rule model</returns>
128128
protected DatabaseDataMaskingRuleModel UpdateRule(DatabaseDataMaskingRuleModel rule)
129129
{
130-
rule.SchemaName = SchemaName;
131-
rule.TableName = TableName;
132-
rule.ColumnName = ColumnName;
130+
if (!string.IsNullOrEmpty(SchemaName)) // only update if the user provided this value
131+
{
132+
rule.SchemaName = SchemaName;
133+
}
134+
135+
if (!string.IsNullOrEmpty(TableName)) // only update if the user provided this value
136+
{
137+
rule.TableName = TableName;
138+
}
139+
140+
if (!string.IsNullOrEmpty(ColumnName)) // only update if the user provided this value
141+
{
142+
rule.ColumnName = ColumnName;
143+
}
144+
133145
if(!string.IsNullOrEmpty(MaskingFunction)) // only update if the user provided this value
134146
{
135147
rule.MaskingFunction = ModelizeMaskingFunction();

0 commit comments

Comments
 (0)