github.com/Ali-iotechsys/sqlboiler/v4@v4.0.0-20221208124957-6aec9a5f1f71/types/pgeo/nullPolygon.go (about) 1 package pgeo 2 3 import ( 4 "database/sql/driver" 5 ) 6 7 // NullPolygon allows polygon to be null 8 type NullPolygon struct { 9 Polygon 10 Valid bool `json:"valid"` 11 } 12 13 // Value for database 14 func (p NullPolygon) Value() (driver.Value, error) { 15 if !p.Valid { 16 return nil, nil 17 } 18 19 return valuePolygon(p.Polygon) 20 } 21 22 // Scan from sql query 23 func (p *NullPolygon) Scan(src interface{}) error { 24 if src == nil { 25 p.Polygon, p.Valid = NewPolygon([]Point{Point{}, Point{}, Point{}, Point{}}), false 26 return nil 27 } 28 29 p.Valid = true 30 return scanPolygon(&p.Polygon, src) 31 } 32 33 // Randomize for sqlboiler 34 func (p *NullPolygon) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) { 35 if shouldBeNull { 36 p.Valid = false 37 return 38 } 39 40 p.Valid = true 41 p.Polygon = randPolygon(nextInt) 42 }