pgtype: Fix -0 for numeric types
Due to the special case of when the digits string was longer than 1 but only contained the negative sign and a 0, it was incorrectly stripping the 0 and attempting to parse "-" as a number. The solution is to check an extra position along to make sure a trailing 0 is not immediately preceeded by a negetive sign. Fixes #543
This commit is contained in:
+1
-1
@@ -321,7 +321,7 @@ func parseNumericString(str string) (n *big.Int, exp int32, err error) {
|
||||
if len(parts) > 1 {
|
||||
exp = int32(-len(parts[1]))
|
||||
} else {
|
||||
for len(digits) > 1 && digits[len(digits)-1] == '0' {
|
||||
for len(digits) > 1 && digits[len(digits)-1] == '0' && digits[len(digits)-2] != '-' {
|
||||
digits = digits[:len(digits)-1]
|
||||
exp++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user