diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7665ab99c9..3ce335e1b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 'View Aggregate' now explicitly applies an ORDER BY count descending.
- New CatalogueItems are now always marked Core (affects drag and drop and new Catalogue creation) - [#1165](https://github.com/HicServices/RDMP/issues/1165),[#1164](https://github.com/HicServices/RDMP/issues/1164)
- If a Catalogue is defined for a Lookup TableInfo then only Core extractable columns will be released (previously all columns were released) [#692](https://github.com/HicServices/RDMP/issues/692)
+- Sql Parameters with no value defined are no longer flagged as Problem by ProblemProvider if they have value sets defined [#1180](https://github.com/HicServices/RDMP/issues/1180)
### Added
@@ -27,6 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed Pin system (anchoring an object to the top of a collection tree).
+### Fixed
+
+- Fixed order of Sql Parameters not always being first in tree
+
## [7.0.12] - 2022-05-16
### Added
diff --git a/Rdmp.Core/OrderableComparer.cs b/Rdmp.Core/OrderableComparer.cs
index 3226f58ca1..3301ce6565 100644
--- a/Rdmp.Core/OrderableComparer.cs
+++ b/Rdmp.Core/OrderableComparer.cs
@@ -4,9 +4,11 @@
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with RDMP. If not, see .
+using System;
using System.Collections;
using System.Collections.Generic;
using MapsDirectlyToDatabaseTable;
+using Rdmp.Core.Curation.Data;
using Rdmp.Core.Curation.Data.Cohort;
using Rdmp.Core.DataExport.Data;
@@ -37,16 +39,19 @@ public OrderableComparer(IComparer nestedComparer)
///
public int Compare(object x, object y)
{
+ var xOrder = GetOrderIfAny(x);
+ var yOrder = GetOrderIfAny(y);
+
//Use IOrderable.Order
- if (x is IOrderable xOrderable && y is IOrderable yOrderable)
- return xOrderable.Order - yOrderable.Order;
+ if (xOrder.HasValue && yOrder.HasValue)
+ return xOrder.Value - yOrder.Value;
- if (x is IOrderable xOnly)
- return xOnly.Order;
+ if (xOrder.HasValue)
+ return xOrder.Value;
// The comparison is reversed (y is orderable) so the order must be negated to.
- if (y is IOrderable yOnly)
- return -yOnly.Order;
+ if (yOrder.HasValue)
+ return -yOrder.Value;
//or use whatever the model is
if (_nestedComparer != null)
@@ -56,6 +61,19 @@ public int Compare(object x, object y)
return string.Compare(x.ToString(), y.ToString());
}
+ private int? GetOrderIfAny(object o)
+ {
+ if(o is IOrderable orderable)
+ return orderable.Order;
+
+ if(o is ISqlParameter)
+ {
+ return -5000;
+ }
+
+ return null;
+ }
+
///
/// Return true if the object should never be reordered and always ordered alphabetically based on it's
///
diff --git a/Rdmp.Core/Providers/CatalogueProblemProvider.cs b/Rdmp.Core/Providers/CatalogueProblemProvider.cs
index 42da1a04e9..27716438ad 100644
--- a/Rdmp.Core/Providers/CatalogueProblemProvider.cs
+++ b/Rdmp.Core/Providers/CatalogueProblemProvider.cs
@@ -98,13 +98,26 @@ public string DescribeProblem(AllCataloguesUsedByLoadMetadataNode allCataloguesU
public string DescribeProblem(ISqlParameter parameter)
{
- if (string.IsNullOrWhiteSpace(parameter.Value) || parameter.Value == AnyTableSqlParameter.DefaultValue)
- return "No value defined";
-
-
if (AnyTableSqlParameter.HasProhibitedName(parameter))
return "Parameter name is a reserved name for the RDMP software";
+ // if parameter has no value thats a problem
+ if (string.IsNullOrWhiteSpace(parameter.Value) || parameter.Value == AnyTableSqlParameter.DefaultValue)
+ {
+ // unless it has ExtractionFilterParameterSets defined on it
+ var desc = _childProvider.GetDescendancyListIfAnyFor(parameter);
+ if (desc != null && parameter is ExtractionFilterParameter)
+ {
+ var filter = desc.Parents.OfType().FirstOrDefault();
+ if (filter != null && filter.ExtractionFilterParameterSets.Any())
+ {
+ return null;
+ }
+ }
+
+ return "No value defined";
+ }
+
return null;
}