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

Add features: decimal_support/empty_is_null #140

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gaoqiangz
Copy link

This PR adds two features decimal_support and empty_is_null.

Feature decimal_support #115

The decimal_support feature enables support for Decimal float type calculation using the rust_decimal library.
Note that due to limitations in the rust_decimal library, certain math calculations are not supported.,the following built-in functions are not available:

  • log
  • log2
  • exp2
  • acos
  • cosh
  • acosh
  • asin
  • sinh
  • asinh
  • atan
  • tanh
  • atanh
  • atan2
  • cbrt
  • hypot
  • is_nan
  • is_finite
  • is_infinite
  • is_normal

Feature empty_is_null

The empty_is_null feature ensures that calculations involving the Empty type behave similarly to Null, following the SQL Null standard (https://en.wikipedia.org/wiki/Null_(SQL)).

use evalexpr::*;

assert_eq!(eval("1 + 2 + ()"), Ok(Value::Empty)));
assert_eq!(eval("() * 2"), Ok(Value::Empty)));
assert_eq!(eval("2 / () "), Ok(Value::Empty)));
assert_eq!(eval("true && () "), Ok(Value::Empty)));
assert_eq!(eval("true || ()"), Ok(Value::Boolean(true))));
assert_eq!(eval("false || ()"), Ok(Value::Empty)));

@ISibboI
Copy link
Owner

ISibboI commented Jul 12, 2023

Thank you for the pull request. I agree that supporting rust_decimal would be great for this crate! However I have doubts about the maintainability of the changes made in this pull request, as they are introducing a vast number of conditional compilation. I have before planned to support custom numeric types in a different way via generics, but did not have time for that yet. Merging this pull request would not make it easier to make the numeric types generic, hence I am sorry but I have to reject this pull request.

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

Successfully merging this pull request may close these issues.

None yet

2 participants