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