2
0

Numeric numberTextBytes() workaround...

This seems a bit of a hack. It fixes the problems demonstrated in my previous commit.

Maybe there's a cleaner way?

Associated: https://github.com/jackc/pgx/issues/1426
This commit is contained in:
Mark Chambers
2023-01-04 01:12:11 +00:00
committed by Jack Christensen
parent 37c6f97b11
commit c46d792c93
+7
View File
@@ -243,7 +243,14 @@ func (n Numeric) MarshalJSON() ([]byte, error) {
// numberString returns a string of the number. undefined if NaN, infinite, or NULL
func (n Numeric) numberTextBytes() []byte {
intStr := n.Int.String()
buf := &bytes.Buffer{}
if len(intStr) > 0 && intStr[:1] == "-" {
intStr = intStr[1:]
buf.WriteByte('-')
}
exp := int(n.Exp)
if exp > 0 {
buf.WriteString(intStr)