pgtype.Numeric numberTextBytes() encoding bug
Demonstrate the problem with the tests:
...for negative decimal values e.g. -0.01
This causes errors when encoding to JSON:
"json: error calling MarshalJSON for type pgtype.Numeric"
It also causes scan failures of sql.NullFloat64:
"converting driver.Value type string ("0.-1") to a float64"
As reported here: https://github.com/jackc/pgx/issues/1426
This commit is contained in:
committed by
Jack Christensen
parent
74f9b9f0a4
commit
37c6f97b11
@@ -213,6 +213,12 @@ func TestNumericMarshalJSON(t *testing.T) {
|
||||
{"123e-3"},
|
||||
{"243723409723490243842378942378901237502734019231380123e23790"},
|
||||
{"3409823409243892349028349023482934092340892390101e-14021"},
|
||||
{"-1.1"},
|
||||
{"-1.0231"},
|
||||
{"-10.0231"},
|
||||
{"-0.1"}, // failed with "invalid character '.' in numeric literal"
|
||||
{"-0.01"}, // failed with "invalid character '-' after decimal point in numeric literal"
|
||||
{"-0.001"}, // failed with "invalid character '-' after top-level value"
|
||||
} {
|
||||
var num pgtype.Numeric
|
||||
var pgJSON string
|
||||
|
||||
Reference in New Issue
Block a user