Skip to content

Commit

Permalink
Merge pull request cockroachdb#71307 from cockroachdb/blathers/backpo…
Browse files Browse the repository at this point in the history
…rt-release-20.2-71110

release-20.2: geo: fix invalid GeoJSON output
  • Loading branch information
otan authored Oct 25, 2021
2 parents 7394fc5 + f970f50 commit 0b4fd4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/geo/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ func parseGeoJSON(
if err := geojson.Unmarshal(b, &t); err != nil {
return geopb.SpatialObject{}, err
}
if t == nil {
return geopb.SpatialObject{}, errors.Newf("invalid GeoJSON input")
}
if defaultSRID != 0 && t.SRID() == 0 {
AdjustGeomTSRID(t, defaultSRID)
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/geospatial
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ SELECT
----
true true

statement error invalid GeoJSON input
select st_geomfromgeojson(json_typeof('null'))

statement error invalid GeoJSON input
select st_geogfromgeojson(json_typeof('null'))

query TTTTTTT
SELECT
ST_AsText(geom),
Expand Down

0 comments on commit 0b4fd4e

Please sign in to comment.