Skip to content

Commit 4423492

Browse files
committed
fix(filter): Fixed filtering on nullable datetime
1 parent 2adadf7 commit 4423492

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/GoatQuery/src/Evaluator/FilterEvaluator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public static Result<Expression> Evaluate(QueryExpression expression, ParameterE
5252
value = Expression.Constant(literal.Value, property.Type);
5353
break;
5454
case DateLiteral literal:
55-
property = Expression.Property(property, "Date");
55+
property = property.Type == typeof(DateTime?) ?
56+
Expression.Property(Expression.Property(property, "Value"), "Date") :
57+
Expression.Property(property, "Date");
5658

5759
value = Expression.Constant(literal.Value.Date, property.Type);
5860
break;

src/GoatQuery/tests/User.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public record User
88
public decimal? BalanceDecimal { get; set; }
99
public double? BalanceDouble { get; set; }
1010
public float? BalanceFloat { get; set; }
11-
public DateTime DateOfBirth { get; set; }
11+
public DateTime? DateOfBirth { get; set; }
1212
}
1313

1414
public sealed record CustomJsonPropertyUser : User

0 commit comments

Comments
 (0)