2
0

Add Float8range

PostgreSQL doesn't define float8range out of the box though it can
easily be created by the user. However, it is still convenient to treat
a numrange as a float8range.
This commit is contained in:
Jack Christensen
2022-02-05 08:54:38 -06:00
parent a74ebc9e51
commit 0355d2ffea
3 changed files with 65 additions and 1 deletions
+36
View File
@@ -216,3 +216,39 @@ func (r *Daterange) SetBoundTypes(lower, upper BoundType) error {
r.Valid = true
return nil
}
type Float8range struct {
Lower Float8
Upper Float8
LowerType BoundType
UpperType BoundType
Valid bool
}
func (r Float8range) IsNull() bool {
return !r.Valid
}
func (r Float8range) BoundTypes() (lower, upper BoundType) {
return r.LowerType, r.UpperType
}
func (r Float8range) Bounds() (lower, upper interface{}) {
return &r.Lower, &r.Upper
}
func (r *Float8range) ScanNull() error {
*r = Float8range{}
return nil
}
func (r *Float8range) ScanBounds() (lowerTarget, upperTarget interface{}) {
return &r.Lower, &r.Upper
}
func (r *Float8range) SetBoundTypes(lower, upper BoundType) error {
r.LowerType = lower
r.UpperType = upper
r.Valid = true
return nil
}