Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null value smaller than any numeric #126

Open
darkterror-jl opened this issue Nov 14, 2022 · 6 comments
Open

null value smaller than any numeric #126

darkterror-jl opened this issue Nov 14, 2022 · 6 comments

Comments

@darkterror-jl
Copy link

darkterror-jl commented Nov 14, 2022

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?

@bijington
Copy link
Owner

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

@darkterror-jl
Copy link
Author

darkterror-jl commented Nov 16, 2022

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

Tested with below code, any idea?
image

@darkterror-jl
Copy link
Author

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

@darkterror-jl
Copy link
Author

darkterror-jl commented Nov 16, 2022

take a look #128

@darkterror-jl
Copy link
Author

@bijington any idea?

@bijington
Copy link
Owner

@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

darkterror-jl pushed a commit to darkterror-jl/expressive that referenced this issue Mar 21, 2023
Component:
Changes:
1. try to fix the code smell issue
darkterror-jl pushed a commit to darkterror-jl/expressive that referenced this issue Mar 21, 2023
Component:
Changes:
1. fix code smell issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants