-
Notifications
You must be signed in to change notification settings - Fork 388
feat: Implement Decimal from/to bytes represents #665
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
Conversation
Signed-off-by: Xuanwo <[email protected]>
sdd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values in the tests match what I'd expect from converting manually 👍🏼
liurenjie1024
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Xuanwo for fixing this, generally LGTM! Left some minor points to fix.
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
|
cc @liurenjie1024 and @Fokko to take another look, sorry for the long wait. |
liurenjie1024
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Xuanwo for this great pr, left some minor suggestions!
| if let Type::Primitive(p) = r#type { | ||
| Ok(Self { | ||
| r#type: p, | ||
| literal: PrimitiveLiteral::Int128(decimal.mantissa()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, we need to validate that the precision is large enough to hold this value. For example, if the input decimal is 123456789, and the required precision is 4, then we should throw an error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, and I added a new unit test to cover this case. PTAL, thank you!
Signed-off-by: Xuanwo <[email protected]>
|
cc @Fokko, would you like to take another look? I believe it's good for merging now. |
liurenjie1024
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Xuanwo , LGTM!
Close #663
This PR will implement Decimal from/to bytes represents.