2
0

Fix Box, Circle, and Point NULL

This commit is contained in:
Jack Christensen
2022-01-08 13:29:47 -06:00
parent 58d2d8e453
commit 6a6878bafd
7 changed files with 43 additions and 0 deletions
+12
View File
@@ -50,6 +50,10 @@ func (dst *Box) Scan(src interface{}) error {
// Value implements the database/sql/driver Valuer interface.
func (src Box) Value() (driver.Value, error) {
if !src.Valid {
return nil, nil
}
buf, err := BoxCodec{}.PlanEncode(nil, 0, TextFormatCode, src).Encode(src, nil)
if err != nil {
return nil, err
@@ -90,6 +94,10 @@ func (p *encodePlanBoxCodecBinary) Encode(value interface{}, buf []byte) (newBuf
return nil, err
}
if !box.Valid {
return nil, nil
}
buf = pgio.AppendUint64(buf, math.Float64bits(box.P[0].X))
buf = pgio.AppendUint64(buf, math.Float64bits(box.P[0].Y))
buf = pgio.AppendUint64(buf, math.Float64bits(box.P[1].X))
@@ -105,6 +113,10 @@ func (p *encodePlanBoxCodecText) Encode(value interface{}, buf []byte) (newBuf [
return nil, err
}
if !box.Valid {
return nil, nil
}
buf = append(buf, fmt.Sprintf(`(%s,%s),(%s,%s)`,
strconv.FormatFloat(box.P[0].X, 'f', -1, 64),
strconv.FormatFloat(box.P[0].Y, 'f', -1, 64),