Skip to content

Commit

Permalink
[MySQL] Support Polygon. (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Jun 25, 2024
1 parent acb81bc commit 1a0b9b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions integration_tests/mysql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ CREATE TABLE %s (
c_json JSON,
c_point POINT,
c_geom GEOMETRY NOT NULL,
c_linestring LINESTRING NOT NULL
c_linestring LINESTRING NOT NULL,
c_polygon POLYGON NOT NULL
)
`

Expand Down Expand Up @@ -180,7 +181,9 @@ INSERT INTO %s VALUES (
-- c_geom
ST_GeomFromText('POINT(1 1)'),
-- c_linestring
ST_GeomFromText('LINESTRING(0 0, 1 1, 2 2)')
ST_GeomFromText('LINESTRING(0 0, 1 1, 2 2)'),
-- c_polygon
ST_GeomFromText('POLYGON((0 0, 1 1, 1 0, 0 0))')
)
`

Expand Down Expand Up @@ -468,6 +471,14 @@ const expectedPayloadTemplate = `{
"field": "c_linestring",
"name": "io.debezium.data.geometry.Geometry",
"parameters": null
},
{
"type": "struct",
"optional": false,
"default": null,
"field": "c_polygon",
"name": "io.debezium.data.geometry.Geometry",
"parameters": null
}
],
"optional": false,
Expand Down Expand Up @@ -509,6 +520,10 @@ const expectedPayloadTemplate = `{
"x": 12.34,
"y": 56.78
},
"c_polygon": {
"srid": 0,
"wkb": "AQMAAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"c_set": "one,two",
"c_smallint": 2,
"c_smallint_unsigned": 3,
Expand Down
3 changes: 2 additions & 1 deletion lib/mysql/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ func parseColumnDataType(originalS string) (DataType, *Opts, error) {
return Point, nil, nil
case
"geometry",
"linestring":
"linestring",
"polygon":
return Geometry, nil, nil
default:
return -1, nil, fmt.Errorf("unknown data type: %q", originalS)
Expand Down

0 comments on commit 1a0b9b1

Please sign in to comment.