From 0a8c538d7b56c104fb3815b4657b16fb2e1daf4d Mon Sep 17 00:00:00 2001 From: bashahee <32364196+bashahee@users.noreply.github.com> Date: Fri, 18 Dec 2020 04:50:37 +0200 Subject: [PATCH] SQL Data Classification - Update id split logic (#13746) * Update DataClassificationAdapter.cs * Update DataClassificationAdapter.cs * Update ChangeLog.md * Update DataClassificationAdapter.cs Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> --- src/Sql/Sql/ChangeLog.md | 1 + .../Services/DataClassificationAdapter.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Sql/Sql/ChangeLog.md b/src/Sql/Sql/ChangeLog.md index 479e453a8c54..fc2be7e4a2bd 100644 --- a/src/Sql/Sql/ChangeLog.md +++ b/src/Sql/Sql/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Upcoming Release * Fixed parameter description for `InstanceFailoverGroup` command. +* Updated the logic in which schemaName, tableName and columnName are being extracted from the id of SQL Data Classification commands. * Fixed Status and StatusMessage fields in `Get-AzSqlDatabaseImportExportStatus` to conform to documentation ## Version 2.13.0 diff --git a/src/Sql/Sql/DataClassification/Services/DataClassificationAdapter.cs b/src/Sql/Sql/DataClassification/Services/DataClassificationAdapter.cs index edf72dd529d3..fb8141be4290 100644 --- a/src/Sql/Sql/DataClassification/Services/DataClassificationAdapter.cs +++ b/src/Sql/Sql/DataClassification/Services/DataClassificationAdapter.cs @@ -285,12 +285,14 @@ private static SensitivityLabel ToSensitivityLabel(SensitivityLabelModel sensiti private static SensitivityLabelModel ToSensitivityLabelModel(SensitivityLabel sensitivityLabel) { - string[] idComponents = sensitivityLabel.Id.Split('/'); + var match = new global::System.Text.RegularExpressions.Regex("/schemas/(?.*)/tables/(?.*)/columns/(?.*)/sensitivityLabels/", + global::System.Text.RegularExpressions.RegexOptions.IgnoreCase).Match(sensitivityLabel.Id); + return new SensitivityLabelModel { - SchemaName = idComponents[12], - TableName = idComponents[14], - ColumnName = idComponents[16], + SchemaName = match.Groups["schemaName"].Value, + TableName = match.Groups["tableName"].Value, + ColumnName = match.Groups["columnName"].Value, SensitivityLabel = NullifyStringIfEmpty(sensitivityLabel.LabelName), SensitivityLabelId = NullifyStringIfEmpty(sensitivityLabel.LabelId), InformationType = NullifyStringIfEmpty(sensitivityLabel.InformationType),