bijington/expressive

null value smaller than any numeric

Opened this issue · 6 comments

Describe the bug

var expression = new expressive.Expression("[variable] < 500");
var result = expression.Evaluate(new Dictionary<string, object> { ["variable"] = null });

Expected behavior
result should return False or just throw exception in my opinion?

What result do you get? I suspect it is null. If so the reason for this was to match what C# does when comparing a nullable int to an int. perhaps we could enhance these options to allow for your scenario https://github.com/bijington/expressive/wiki/Usage#custom-options

@bijington thank you for your reply.
Actually the result is True which make me confused

Tested with below code, any idea?
image

But below code does return -1 means null less than numeric
Comparer<object>.Default.Compare(myNullableInt, 1)

take a look #128

@bijington any idea?

Thank you for the submission, sorry I haven't had a chance to review it yet. It is on my queue but I don't have a huge capacity at the moment. I will aim to get to it soon though