diff --git a/lib/debezium/converters/bit.go b/lib/debezium/converters/bit.go index 7eb7a8b4..601eeb6f 100644 --- a/lib/debezium/converters/bit.go +++ b/lib/debezium/converters/bit.go @@ -2,9 +2,8 @@ package converters import ( "fmt" - "github.com/artie-labs/transfer/lib/typing" - "github.com/artie-labs/transfer/lib/debezium" + "github.com/artie-labs/transfer/lib/typing" ) type BitConverter struct{} diff --git a/lib/debezium/converters/decimal.go b/lib/debezium/converters/decimal.go index 419e38fc..1a460eda 100644 --- a/lib/debezium/converters/decimal.go +++ b/lib/debezium/converters/decimal.go @@ -2,9 +2,8 @@ package converters import ( "fmt" - "github.com/artie-labs/transfer/lib/typing" - "github.com/artie-labs/transfer/lib/debezium" + "github.com/artie-labs/transfer/lib/typing" "github.com/cockroachdb/apd/v3" ) diff --git a/lib/debezium/converters/enum.go b/lib/debezium/converters/enum.go index d8cc05b6..b02cb363 100644 --- a/lib/debezium/converters/enum.go +++ b/lib/debezium/converters/enum.go @@ -1,9 +1,8 @@ package converters import ( - "fmt" - "github.com/artie-labs/transfer/lib/debezium" + "github.com/artie-labs/transfer/lib/typing" ) type EnumConverter struct{} @@ -17,11 +16,12 @@ func (EnumConverter) ToField(name string) debezium.Field { } func (EnumConverter) Convert(value any) (any, error) { - castValue, isOk := value.(string) - if isOk { - return castValue, nil + castedValue, err := typing.AssertType[string](value) + if err != nil { + return nil, err } - return nil, fmt.Errorf("expected string got %T with value: %v", value, value) + + return castedValue, nil } type EnumSetConverter struct{} @@ -35,9 +35,10 @@ func (EnumSetConverter) ToField(name string) debezium.Field { } func (EnumSetConverter) Convert(value any) (any, error) { - castValue, isOk := value.(string) - if isOk { - return castValue, nil + castedValue, err := typing.AssertType[string](value) + if err != nil { + return nil, err } - return nil, fmt.Errorf("expected string got %T with value: %v", value, value) + + return castedValue, nil }