github.com/Ali-iotechsys/sqlboiler/v4@v4.0.0-20221208124957-6aec9a5f1f71/types/pgeo/nullPoint.go (about) 1 package pgeo 2 3 import ( 4 "database/sql/driver" 5 ) 6 7 // NullPoint allows point to be null 8 type NullPoint struct { 9 Point 10 Valid bool `json:"valid"` 11 } 12 13 // Value for database 14 func (p NullPoint) Value() (driver.Value, error) { 15 if !p.Valid { 16 return nil, nil 17 } 18 19 return valuePoint(p.Point) 20 } 21 22 // Scan from sql query 23 func (p *NullPoint) Scan(src interface{}) error { 24 if src == nil { 25 p.Point, p.Valid = NewPoint(0, 0), false 26 return nil 27 } 28 29 p.Valid = true 30 return scanPoint(&p.Point, src) 31 } 32 33 // Randomize for sqlboiler 34 func (p *NullPoint) 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.Point = randPoint(nextInt) 42 }