Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Aug 14, 2024
1 parent ae9944b commit 23312b1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions lib/debezium/converters/bit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
3 changes: 1 addition & 2 deletions lib/debezium/converters/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
21 changes: 11 additions & 10 deletions lib/debezium/converters/enum.go
Original file line number Diff line number Diff line change
@@ -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{}
Expand All @@ -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{}
Expand All @@ -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
}

0 comments on commit 23312b1

Please sign in to comment.