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