diff --git a/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs b/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs index 9770ff2dd8..ab1f72482d 100644 --- a/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs +++ b/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs @@ -42,7 +42,10 @@ public OverviewModel(IBasicActivateItems activator, ICatalogue catalogue) { _activator = activator; _catalogue = catalogue; - Regen(""); + if (catalogue != null) + { + Regen(""); + } } public void Regen(string whereClause) @@ -55,6 +58,7 @@ public void Regen(string whereClause) column = _catalogue.CatalogueItems.FirstOrDefault(); hasExtractionIdentifier = false; } + if (column is null) return; var discoveredColumn = column.ColumnInfo.Discover(DataAccessContext.InternalDataProcessing); var server = discoveredColumn.Table.Database.Server; using var con = server.GetConnection(); diff --git a/Rdmp.UI.Tests/ForEachUITests.cs b/Rdmp.UI.Tests/ForEachUITests.cs index e8c77b9a66..0cfc4eda87 100644 --- a/Rdmp.UI.Tests/ForEachUITests.cs +++ b/Rdmp.UI.Tests/ForEachUITests.cs @@ -6,6 +6,8 @@ using NUnit.Framework; using Rdmp.Core.CommandExecution.AtomicCommands; +using Rdmp.Core.Curation.Data; +using Rdmp.UI.Overview; using Tests.Common; namespace Rdmp.UI.Tests; @@ -29,4 +31,14 @@ public void ForEachUI_Test_GetTabName() }); }); } + + [Test, UITimeout(20000)] + public void Test_ViewCatalogueOverviewUI_Constructor() + { + var o = WhenIHaveA(); + var ui = AndLaunch(o); + //Assert.IsNotNull(ui); + //AssertNoErrors(ExpectedErrorType.Fatal); + //AssertNoErrors(ExpectedErrorType.KilledForm); + } } \ No newline at end of file diff --git a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs index 25743e90df..f6ab5356aa 100644 --- a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs +++ b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs @@ -77,10 +77,17 @@ private void UpdateCatalogueData() { lblLatestExtraction.Text = "Catalogue has not been extracted"; } - var syntaxHelper = _catalogue.GetDistinctLiveDatabaseServer(DataAccessContext.InternalDataProcessing, false).GetQuerySyntaxHelper(); - var dateTypeString = syntaxHelper.TypeTranslater.GetSQLDBTypeForCSharpType(new TypeGuesser.DatabaseTypeRequest(typeof(DateTime))); - + try + { + var syntaxHelper = _catalogue.GetDistinctLiveDatabaseServer(DataAccessContext.InternalDataProcessing, false)?.GetQuerySyntaxHelper(); + var dateTypeString = syntaxHelper.TypeTranslater.GetSQLDBTypeForCSharpType(new TypeGuesser.DatabaseTypeRequest(typeof(DateTime))); + _dateColumns = _catalogue.CatalogueItems.Where(ci => ci.ColumnInfo.Data_type == dateTypeString).ToList(); + } + catch + { + return; + } cbTimeColumns.Items.Clear(); cbTimeColumns.Items.AddRange(_dateColumns.ToArray()); var pks = _dateColumns.Where(ci => ci.ColumnInfo.IsPrimaryKey).ToList();