diff --git a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandPerformRegexRedactionOnCatalogue.cs b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandPerformRegexRedactionOnCatalogue.cs index 5543c1faf2..c5bb0cb846 100644 --- a/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandPerformRegexRedactionOnCatalogue.cs +++ b/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandPerformRegexRedactionOnCatalogue.cs @@ -60,11 +60,14 @@ public override void Execute() { redactionsToSaveTable = RegexRedactionHelper.GenerateRedactionsDataTable(); pksToSave = RegexRedactionHelper.GeneratePKDataTable(); + var columnName = columnInfo.Name; var table = columnInfo.TableInfo.Name; + _discoveredTable = columnInfo.TableInfo.Discover(DataAccessContext.InternalDataProcessing); DiscoveredColumn[] discoveredColumns = _discoveredTable.DiscoverColumns(); _discoveredPKColumns = discoveredColumns.Where(c => c.IsPrimaryKey).ToArray(); + if (_discoveredPKColumns.Length != 0) { _cataloguePKs = _catalogue.CatalogueItems.Where(c => c.ColumnInfo.IsPrimaryKey).ToList(); @@ -81,6 +84,7 @@ public override void Execute() qb.TopX = (int)_readLimit; } var sql = qb.SQL; + var dt = new DataTable(); dt.BeginLoadData(); var conn = _server.GetConnection(); @@ -92,6 +96,7 @@ public override void Execute() da.Fill(dt); } conn.Close(); + redactionUpates = dt.Clone(); redactionUpates.BeginLoadData(); foreach (DataRow row in dt.Rows) @@ -134,7 +139,6 @@ public override void Execute() throw new Exception($"Unable to identify any primary keys in table '{table}'. Redactions cannot be performed on tables without primary keys"); } resultCount += redactionUpates.Rows.Count; - } } }