diff --git a/src/Foundatio.Parsers.SqlQueries/Extensions/SqlNodeExtensions.cs b/src/Foundatio.Parsers.SqlQueries/Extensions/SqlNodeExtensions.cs index fd6e765e..008325ba 100644 --- a/src/Foundatio.Parsers.SqlQueries/Extensions/SqlNodeExtensions.cs +++ b/src/Foundatio.Parsers.SqlQueries/Extensions/SqlNodeExtensions.cs @@ -204,7 +204,7 @@ private static void AppendField(StringBuilder builder, EntityFieldInfo field, st if (field == null) return; - if (field.IsNumber || field.IsBoolean) + if (field.IsNumber || field.IsBoolean || field.IsMoney) builder.Append(term); else if (field is { IsDate: true }) builder.Append("DateTime.Parse(\"" + term + "\")"); @@ -226,8 +226,8 @@ public static string ToSqlString(this TermRangeNode node, ISqlQueryVisitorContex return query; var field = GetFieldInfo(context.Fields, node.Field); - if (!field.IsNumber && !field.IsDate) - context.AddValidationError("Field must be a number or date for term range queries."); + if (!field.IsNumber && !field.IsDate && !field.IsMoney) + context.AddValidationError("Field must be a number, money or date for term range queries."); var builder = new StringBuilder(); diff --git a/src/Foundatio.Parsers.SqlQueries/Visitors/SqlQueryVisitorContext.cs b/src/Foundatio.Parsers.SqlQueries/Visitors/SqlQueryVisitorContext.cs index 766e19bd..469af6d8 100644 --- a/src/Foundatio.Parsers.SqlQueries/Visitors/SqlQueryVisitorContext.cs +++ b/src/Foundatio.Parsers.SqlQueries/Visitors/SqlQueryVisitorContext.cs @@ -10,11 +10,12 @@ public class SqlQueryVisitorContext : QueryVisitorContext, ISqlQueryVisitorConte public IEntityType EntityType { get; set; } } -[DebuggerDisplay("{Field} IsNumber: {IsNumber} IsDate: {IsDate} IsBoolean: {IsBoolean} IsCollection: {IsCollection}")] +[DebuggerDisplay("{Field} IsNumber: {IsNumber} IsMoney: {IsMoney} IsDate: {IsDate} IsBoolean: {IsBoolean} IsCollection: {IsCollection}")] public class EntityFieldInfo { public string Field { get; set; } public bool IsNumber { get; set; } + public bool IsMoney { get; set; } public bool IsDate { get; set; } public bool IsBoolean { get; set; } public bool IsCollection { get; set; } diff --git a/tests/Foundatio.Parsers.SqlQueries.Tests/SqlQueryParserTests.cs b/tests/Foundatio.Parsers.SqlQueries.Tests/SqlQueryParserTests.cs index bd620f59..8091c5c7 100644 --- a/tests/Foundatio.Parsers.SqlQueries.Tests/SqlQueryParserTests.cs +++ b/tests/Foundatio.Parsers.SqlQueries.Tests/SqlQueryParserTests.cs @@ -254,6 +254,9 @@ public override IQueryNode Visit(TermNode node, IQueryVisitorContext context) customFieldBuilder.Append(" AND "); switch (field) { + case { IsMoney: true }: + customFieldBuilder.Append("MoneyValue"); + break; case { IsNumber: true }: customFieldBuilder.Append("NumberValue"); break;