-
Notifications
You must be signed in to change notification settings - Fork 573
Description
Describe the bug
Check isNonNegative() doesn't work correctly cause of conversion problem. This function uses satisfies() function and in this MR #312 authour decided to use DECIMAL(20,10) with precision = 20 and scale = 10. Integer digits available to store is 20 - 10 = 10 digits, so the maximum value is 10⁹ - 1 = 999,999,999. Maximum bigInt value is 9,223,372,036,854,775,807 (19 digits) that's why all digits X > 999,999,999 and X < -999,999,999 are converted to 0.0 with COALESCE(CAST($column AS DECIMAL(20,10)), 0.0) function
To Reproduce
isNonNegative() uses satisfies() function, so you may use the expression COALESCE(CAST($column AS DECIMAL(20,10)), 0.0) and any value insted of $column to see the results
Expected behavior
For the bigint data type it's better to convert using DECIMAL(38,0) expression
For data types using floating-point it's better to create another check with decimal and scale parameters in it, e.g. isNonNegativeDecimal()
