Skip to content

Commit

Permalink
Fix type check for ST_ExteriorRing
Browse files Browse the repository at this point in the history
Remove MultiPolygons as acceptable type for ST_ExteriorRing, which
only works for Polygons.

Fixes #10875
  • Loading branch information
jwass authored and mbasmanova committed Jun 20, 2018
1 parent 72cd069 commit be6c175
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Expand Up @@ -694,7 +694,7 @@ public static double stDistance(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlTyp
public static Slice stExteriorRing(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
OGCGeometry geometry = deserialize(input);
validateType("ST_ExteriorRing", geometry, EnumSet.of(POLYGON, MULTI_POLYGON));
validateType("ST_ExteriorRing", geometry, EnumSet.of(POLYGON));
if (geometry.isEmpty()) {
return null;
}
Expand Down
Expand Up @@ -549,7 +549,8 @@ public void testSTExteriorRing()
assertFunction("ST_AsText(ST_ExteriorRing(ST_GeometryFromText('POLYGON EMPTY')))", VARCHAR, null);
assertFunction("ST_AsText(ST_ExteriorRing(ST_GeometryFromText('POLYGON ((1 1, 1 4, 4 1))')))", VARCHAR, "LINESTRING (1 1, 4 1, 1 4, 1 1)");
assertFunction("ST_AsText(ST_ExteriorRing(ST_GeometryFromText('POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))')))", VARCHAR, "LINESTRING (0 0, 5 0, 5 5, 0 5, 0 0)");
assertInvalidFunction("ST_AsText(ST_ExteriorRing(ST_GeometryFromText('LINESTRING (1 1, 2 2, 1 3)')))", "ST_ExteriorRing only applies to POLYGON or MULTI_POLYGON. Input type is: LINE_STRING");
assertInvalidFunction("ST_AsText(ST_ExteriorRing(ST_GeometryFromText('LINESTRING (1 1, 2 2, 1 3)')))", "ST_ExteriorRing only applies to POLYGON. Input type is: LINE_STRING");
assertInvalidFunction("ST_AsText(ST_ExteriorRing(ST_GeometryFromText('MULTIPOLYGON (((1 1, 2 2, 1 3, 1 1)), ((4 4, 5 5, 4 6, 4 4)))')))", "ST_ExteriorRing only applies to POLYGON. Input type is: MULTI_POLYGON");
}

@Test
Expand Down

0 comments on commit be6c175

Please sign in to comment.