-
Notifications
You must be signed in to change notification settings - Fork 209
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
Implement BIT_SHIFT_LEFT operation #1286
Conversation
Body : Defined a new type to support bit shift operation and added a logic to pass from sqlparesr to gluesql ast builder
Body : Basically the structure of function is similar to other binary operations. But i added new vriant of LiteralError to make error-handling more sense
Body : This needs to make the statement executable.
Pull Request Test Coverage Report for Build 5629113870
💛 - Coveralls |
…bit-operation To apply requirements in pull request review
…ion" This reverts commit e5c9707. The purpose of this commit is to discard unrelated changes in pull request
Body: Added explicit error handling, also handled exceptional cases
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.
https://docs.rs/num-traits/latest/num_traits/ops/checked/trait.CheckedShl.html
According to above docs, it is true that 'checked_shl' was implemented for most of primitive integer types. However it seems that 'rhs' parameter for checked_shl is 'u32' type.
When i ran the test cases i wrote in suite, i always got the I64 Value type as a result. That's why i added this conversion funtionality into this module.
If there is anything i misunderstood , pls feedback )
We don't need to use it would be better to see the doc of rust primitive integer types. |
1. shift_left -> bitwise_shift_left 2. ShiftLeft -> BitwiseShiftLeft
I separated rhs match expression from original match pattern so that it can remove duplicated parts in the previous implementation
i also covered some missed lines
Also reflected the changes into related files
1. Removed 'validate_bitwise_shift_rhs' because it was only being used by this function 2. Deleted duplicated error handling because we can treat it in ok_or_else parenthesis when the 'checked_shl' fail
Following review request, i added if statement to keep consistency if rhs is Null value by return Ok(Null)
1. Separated test cases into additional unit test case block. 2. Added new error variant into 'LiteralError' enum 3. Edit the implementation detail of bitwise_shift_left to handle explicit error handling
New error variant list : - BitwiseNonIntegerOperand for a operand that is Number literal, but not an integer type - BitwiseNonNumberLiteral for non number literal type - BitwiseOperationOverflow for overflow exception case - ImpossibleConversion when it is impossible to cast a value to another type
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.
Looks all great! Thanks a lot for the contribution 👍 👍
From the issue #1271,
Added below key features to several modules in core directory.