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

fix intDiv div operation and more edge cases with precision for all arithmetic operations #1397

Merged
merged 7 commits into from
Nov 11, 2022

Conversation

jennifersp
Copy link
Contributor

@jennifersp jennifersp commented Nov 11, 2022

IntDiv does operations in decimal type values and returns the int part of the decimal value result. If the value goes out of bound of int64, it errors.

Fixed few more edge cases for all arithmetic operations including:

  • any time type value gets parsed as int value with pattern of YYYYMMDDHHMMSS or YYYYMMDD depending on what's defined. This applies to all arithmetic operations.
  • invalid string tries to parse available numbers from the beginning of the string value and used in the arithmetic operation. 12.4ag3.2jgw499 is parsed as number 12.4, and a942.6ng488 is parsed as 0.

Copy link
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Only one small suggestion about using a little more regex in one place to simplify your parsing code.

sql/numbertype.go Outdated Show resolved Hide resolved
@jennifersp jennifersp merged commit 0f4558a into main Nov 11, 2022
@jennifersp jennifersp deleted the jennifer/intdiv branch November 11, 2022 21:25
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