mirror of
https://github.com/jackc/pgx.git
synced 2025-05-30 19:22:19 +00:00
feat: add marshalJSON for float8 type
This commit is contained in:
parent
639fb28846
commit
72e4b88e56
@ -3,6 +3,7 @@ package pgtype
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
@ -108,6 +109,13 @@ func (Float8Codec) PlanEncode(m *Map, oid uint32, format int16, value any) Encod
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Float8) MarshalJSON() ([]byte, error) {
|
||||
if !f.Valid {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
return json.Marshal(f.Float64)
|
||||
}
|
||||
|
||||
type encodePlanFloat8CodecBinaryFloat64 struct{}
|
||||
|
||||
func (encodePlanFloat8CodecBinaryFloat64) Encode(value any, buf []byte) (newBuf []byte, err error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user