Skip to content

Commit

Permalink
Fix misleading doc comments regarding validation
Browse files Browse the repository at this point in the history
There were some doc comments for JSON unmarshalling and SQL (WKB)
scanning that referenced constructor options. This change updates the
documentation to refer to `NoValidate` instead.
  • Loading branch information
peterstace committed Jan 31, 2024
1 parent 24d3418 commit a8fb92c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
17 changes: 9 additions & 8 deletions geom/type_geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,11 @@ func (g Geometry) MarshalJSON() ([]byte, error) {
// UnmarshalJSON implements the encoding/json.Unmarshaller interface by
// parsing the JSON stream as GeoJSON geometry object.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be unmarshalled into a
// json.RawMessage value and then UnmarshalJSON called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the GeoJSON value should be scanned into a
// json.RawMessage value and then UnmarshalJSON called manually (passing in
// NoValidate{}).
func (g *Geometry) UnmarshalJSON(p []byte) error {
geom, err := UnmarshalGeoJSON(p)
if err != nil {
Expand Down Expand Up @@ -345,10 +346,10 @@ func (g Geometry) Value() (driver.Value, error) {
// Scan implements the database/sql.Scanner interface by parsing the src value
// as WKB (Well Known Binary).
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (g *Geometry) Scan(src interface{}) error {
var wkb []byte
switch src := src.(type) {
Expand Down
8 changes: 4 additions & 4 deletions geom/type_geometry_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ func (c GeometryCollection) Value() (driver.Value, error) {
// If the WKB doesn't represent a GeometryCollection geometry, then an error is
// returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (c *GeometryCollection) Scan(src interface{}) error {
return scanAsType(src, c)
}
Expand Down
8 changes: 4 additions & 4 deletions geom/type_line_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ func (s LineString) Value() (driver.Value, error) {
//
// If the WKB doesn't represent a LineString geometry, then an error is returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (s *LineString) Scan(src interface{}) error {
return scanAsType(src, s)
}
Expand Down
8 changes: 4 additions & 4 deletions geom/type_multi_line_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ func (m MultiLineString) Value() (driver.Value, error) {
//
// If the WKB doesn't represent a MultiLineString geometry, then an error is returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (m *MultiLineString) Scan(src interface{}) error {
return scanAsType(src, m)
}
Expand Down
8 changes: 4 additions & 4 deletions geom/type_multi_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ func (m MultiPoint) Value() (driver.Value, error) {
//
// If the WKB doesn't represent a MultiPoint geometry, then an error is returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (m *MultiPoint) Scan(src interface{}) error {
return scanAsType(src, m)
}
Expand Down
8 changes: 4 additions & 4 deletions geom/type_multi_polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ func (m MultiPolygon) Value() (driver.Value, error) {
//
// If the WKB doesn't represent a MultiPolygon geometry, then an error is returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (m *MultiPolygon) Scan(src interface{}) error {
return scanAsType(src, m)
}
Expand Down
8 changes: 4 additions & 4 deletions geom/type_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ func (p Point) Value() (driver.Value, error) {
//
// If the WKB doesn't represent a Point geometry, then an error is returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (p *Point) Scan(src interface{}) error {
return scanAsType(src, p)
}
Expand Down
8 changes: 4 additions & 4 deletions geom/type_polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ func (p Polygon) Value() (driver.Value, error) {
//
// If the WKB doesn't represent a Polygon geometry, then an error is returned.
//
// It constructs the resultant geometry with no ConstructionOptions. If
// ConstructionOptions are needed, then the value should be scanned into a byte
// slice and then UnmarshalWKB called manually (passing in the
// ConstructionOptions as desired).
// Geometry constraint validation is performed on the resultant geometry (an
// error will be returned if the geometry is invalid). If this validation isn't
// needed or is undesirable, then the WKB should be scanned into a byte slice
// and then UnmarshalWKB called manually (passing in NoValidate{}).
func (p *Polygon) Scan(src interface{}) error {
return scanAsType(src, p)
}
Expand Down

0 comments on commit a8fb92c

Please sign in to comment.