diff --git a/lib/cdc/util/parse.go b/lib/cdc/util/parse.go index 38c2e6d7d..0a6af7ebc 100644 --- a/lib/cdc/util/parse.go +++ b/lib/cdc/util/parse.go @@ -36,6 +36,7 @@ func parseField(field debezium.Field, value interface{}) interface{} { } case debezium.GeometryType, debezium.GeographyType: geometryString, err := parseGeometry(value) + fmt.Println("err", err) if err == nil { return geometryString } diff --git a/lib/cdc/util/parse_test.go b/lib/cdc/util/parse_test.go index b262bbc0b..4ed6e6df6 100644 --- a/lib/cdc/util/parse_test.go +++ b/lib/cdc/util/parse_test.go @@ -90,6 +90,39 @@ func TestParseField(t *testing.T) { expectedValue: "123.45", expectedDecimal: true, }, + { + name: "geometry (no srid)", + field: debezium.Field{ + DebeziumType: string(debezium.GeometryType), + }, + value: map[string]interface{}{ + "srid": nil, + "wkb": "AQEAAAAAAAAAAADwPwAAAAAAABRA", + }, + expectedValue: `{"type":"Feature","geometry":{"type":"Point","coordinates":[1,5]},"properties":null}`, + }, + { + name: "geometry (w/ srid)", + field: debezium.Field{ + DebeziumType: string(debezium.GeometryType), + }, + value: map[string]interface{}{ + "srid": 4326, + "wkb": "AQEAACDmEAAAAAAAAAAA8D8AAAAAAAAYQA==", + }, + expectedValue: `{"type":"Feature","geometry":{"type":"Point","coordinates":[1,6]},"properties":null}`, + }, + { + name: "geography (w/ srid)", + field: debezium.Field{ + DebeziumType: string(debezium.GeographyType), + }, + value: map[string]interface{}{ + "srid": 4326, + "wkb": "AQEAACDmEAAAAAAAAADAXkAAAAAAAIBDwA==", + }, + expectedValue: `{"type":"Feature","geometry":{"type":"Point","coordinates":[123,-39]},"properties":null}`, + }, } for _, testCase := range testCases {