Skip to content

Commit

Permalink
[MySQL] Support Linestring (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Jun 24, 2024
1 parent 4df9e9a commit 4867834
Show file tree
Hide file tree
Showing 3 changed files with 316 additions and 299 deletions.
19 changes: 17 additions & 2 deletions integration_tests/mysql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ CREATE TABLE %s (
c_set SET('one', 'two', 'three'),
c_json JSON,
c_point POINT,
c_geom GEOMETRY NOT NULL
c_geom GEOMETRY NOT NULL,
c_linestring LINESTRING NOT NULL
)
`

Expand Down Expand Up @@ -177,7 +178,9 @@ INSERT INTO %s VALUES (
-- c_point
POINT(12.34, 56.78),
-- c_geom
ST_GeomFromText('POINT(1 1)')
ST_GeomFromText('POINT(1 1)'),
-- c_linestring
ST_GeomFromText('LINESTRING(0 0, 1 1, 2 2)')
)
`

Expand Down Expand Up @@ -457,6 +460,14 @@ const expectedPayloadTemplate = `{
"field": "c_geom",
"name": "io.debezium.data.geometry.Geometry",
"parameters": null
},
{
"type": "struct",
"optional": false,
"default": null,
"field": "c_linestring",
"name": "io.debezium.data.geometry.Geometry",
"parameters": null
}
],
"optional": false,
Expand Down Expand Up @@ -487,6 +498,10 @@ const expectedPayloadTemplate = `{
"c_int": 4,
"c_int_unsigned": 55,
"c_json": "{\"key1\": \"value1\", \"key2\": \"value2\"}",
"c_linestring": {
"srid": 0,
"wkb": "AQIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAQAAAAAAAAABA"
},
"c_mediumint": 3,
"c_mediumint_unsigned": 4,
"c_numeric": "AN3M",
Expand Down
4 changes: 2 additions & 2 deletions lib/mysql/schema/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ func ConvertValue(value any, colType DataType) (any, error) {
return nil, fmt.Errorf("expected []byte got %T for value: %v", value, value)
}

if len(bytes) != 25 {
return nil, fmt.Errorf("expected []byte with length 25, length is %d", len(bytes))
if len(bytes) < 25 {
return nil, fmt.Errorf("expected []byte with at least length 25, length is %d", len(bytes))
}

var byteOrder binary.ByteOrder
Expand Down
Loading

0 comments on commit 4867834

Please sign in to comment.