Fix Box, Circle, and Point NULL
This commit is contained in:
@@ -51,6 +51,10 @@ func (dst *Circle) Scan(src interface{}) error {
|
||||
|
||||
// Value implements the database/sql/driver Valuer interface.
|
||||
func (src Circle) Value() (driver.Value, error) {
|
||||
if !src.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
buf, err := CircleCodec{}.PlanEncode(nil, 0, TextFormatCode, src).Encode(src, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -91,6 +95,10 @@ func (p *encodePlanCircleCodecBinary) Encode(value interface{}, buf []byte) (new
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !circle.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
buf = pgio.AppendUint64(buf, math.Float64bits(circle.P.X))
|
||||
buf = pgio.AppendUint64(buf, math.Float64bits(circle.P.Y))
|
||||
buf = pgio.AppendUint64(buf, math.Float64bits(circle.R))
|
||||
@@ -105,6 +113,10 @@ func (p *encodePlanCircleCodecText) Encode(value interface{}, buf []byte) (newBu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !circle.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
buf = append(buf, fmt.Sprintf(`<(%s,%s),%s>`,
|
||||
strconv.FormatFloat(circle.P.X, 'f', -1, 64),
|
||||
strconv.FormatFloat(circle.P.Y, 'f', -1, 64),
|
||||
|
||||
Reference in New Issue
Block a user