diff --git a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/ExpressionExtensions.cs b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/ExpressionExtensions.cs index 5bbff5d8..26995479 100644 --- a/MarkMpn.Sql4Cds.Engine/ExecutionPlan/ExpressionExtensions.cs +++ b/MarkMpn.Sql4Cds.Engine/ExecutionPlan/ExpressionExtensions.cs @@ -133,9 +133,9 @@ private static Expression ToExpression(ColumnReferenceExpression col, NodeSchema { var name = col.GetColumnName(); - if (!schema.ContainsColumn(name, out var normalizedName)) + if (schema == null || !schema.ContainsColumn(name, out var normalizedName)) { - if (!schema.Aliases.TryGetValue(name, out var normalized)) + if (schema == null || !schema.Aliases.TryGetValue(name, out var normalized)) { if (nonAggregateSchema != null && nonAggregateSchema.ContainsColumn(name, out _)) throw new NotSupportedQueryFragmentException("Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause", col); @@ -144,6 +144,10 @@ private static Expression ToExpression(ColumnReferenceExpression col, NodeSchema if (col.MultiPartIdentifier.Identifiers.Count == 1 && col.MultiPartIdentifier.Identifiers[0].QuoteType == QuoteType.DoubleQuote) ex.Suggestion = $"Did you mean '{name}'?"; + else if (name.Equals("false", StringComparison.OrdinalIgnoreCase)) + ex.Suggestion = "Did you mean '0'?"; + else if (name.Equals("true", StringComparison.OrdinalIgnoreCase)) + ex.Suggestion = "Did you mean '1'?"; throw ex; }