Skip to content

Add features: decimal_support/empty_is_null - #140

Open
gaoqiangz wants to merge 6 commits into
ISibboI:mainfrom
gaoqiangz:pr_support_dec_and_null
Open

Add features: decimal_support/empty_is_null#140
gaoqiangz wants to merge 6 commits into
ISibboI:mainfrom
gaoqiangz:pr_support_dec_and_null

Conversation

@gaoqiangz

Copy link
Copy Markdown

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

ISibboI commented Jul 12, 2023

Copy link
Copy Markdown
Owner

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.

@ISibboI
ISibboI force-pushed the main branch 6 times, most recently from e4a8571 to 6608b16 Compare October 11, 2024 15:01
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.

2 participants