Skip to content

Commit

Permalink
Add support for money data type
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Mar 20, 2024
1 parent 9f34eeb commit 41a74a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "\")");
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 41a74a4

Please sign in to comment.