Skip to content

Commit

Permalink
Fix null ref when ExtractionInformation deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
tznind committed Jul 5, 2022
1 parent 1b298ea commit 553e951
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Row size no longer cuts off bottom pixels of column name(s)
- Multi delete is now supported
- Pasted column name(s) with spaces e.g. `[my cool col]` now work
- Fixed null reference in extraction checks when extracting a dataset where the original [ExtractionInformation] has been deleted [#1253](https://github.com/HicServices/RDMP/issues/1253)

## [7.0.14] - 2022-06-27

Expand Down
16 changes: 15 additions & 1 deletion Rdmp.Core/DataExport/Checks/SelectedDataSetsChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ public void Check(ICheckNotifier notifier)
.Select(c => c.CatalogueExtractionInformation)
.ToArray();

var orphans = selectedcols
.OfType<ExtractableColumn>()
.Where(c => c.CatalogueExtractionInformation == null)
.ToArray();

if(orphans.Any())
{
notifier.OnCheckPerformed(
new CheckEventArgs("The following columns no longer map to an ExtractionInformation (it may have been deleted)" + Environment.NewLine
+ string.Join(Environment.NewLine, orphans.Select(o => o.GetRuntimeName()).ToArray()),
CheckResult.Warning));
}


WarnAboutExtractionCategory(notifier, config, ds,eis, ErrorCodes.ExtractionContainsSpecialApprovalRequired, ExtractionCategory.SpecialApprovalRequired);
WarnAboutExtractionCategory(notifier, config, ds, eis, ErrorCodes.ExtractionContainsInternal, ExtractionCategory.Internal);
WarnAboutExtractionCategory(notifier, config, ds, eis, ErrorCodes.ExtractionContainsDeprecated, ExtractionCategory.Deprecated);
Expand Down Expand Up @@ -284,7 +298,7 @@ private bool IsTextDatatype(IColumn arg)
/// <param name="category"></param>
public static void WarnAboutExtractionCategory(ICheckNotifier notifier, IExtractionConfiguration configuration, IExtractableDataSet dataset, ExtractionInformation[] cols, ErrorCode errorCode, ExtractionCategory category)
{
if (cols.Any(c => c.ExtractionCategory == category))
if (cols.Any(c => c?.ExtractionCategory == category))
{
notifier.OnCheckPerformed(new CheckEventArgs(errorCode, configuration, dataset,
String.Join(",", cols.Where(c => c.ExtractionCategory == category)
Expand Down

1 comment on commit 553e951

@tznind
Copy link
Contributor Author

@tznind tznind commented on 553e951 Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Please sign in to comment.