Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skipping unknown type when silent is true #251

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions pkg/toolkit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,16 @@ func TryRegisterCustomTypes(typeMap *pgtype.Map, types []*Type, silent bool) {
if t.Kind == 'd' {
if t.BaseType != 0 {
baseType, ok := typeMap.TypeForOID(uint32(t.BaseType))
if !ok && !silent {
log.Warn().
Str("Context", "CustomTypeRegistering").
Str("Schema", t.Schema).
Str("Name", t.Name).
Int("Oid", int(t.Oid)).
Str("Kind", fmt.Sprintf("%c", t.Kind)).
Msg("unable to register domain type")
if !ok {
if !silent {
log.Warn().
Str("Context", "CustomTypeRegistering").
Str("Schema", t.Schema).
Str("Name", t.Name).
Int("Oid", int(t.Oid)).
Str("Kind", fmt.Sprintf("%c", t.Kind)).
Msg("unable to register domain type")
}
continue
}
typeMap.RegisterType(&pgtype.Type{
Copy link
Contributor

@wwoytenko wwoytenko Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add fix for Array type registering as well (it's below) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

Expand All @@ -146,14 +148,17 @@ func TryRegisterCustomTypes(typeMap *pgtype.Map, types []*Type, silent bool) {
Codec: baseType.Codec,
})
arrayType, ok := typeMap.TypeForName(fmt.Sprintf("_%s", baseType.Name))
if !ok && !silent {
log.Warn().
Str("Context", "CustomTypeRegistering").
Str("Schema", t.Schema).
Str("Name", t.Name).
Int("Oid", int(t.Oid)).
Msg("cannot register array type for custom type")
if !ok {
if !silent {
log.Warn().
Str("Context", "CustomTypeRegistering").
Str("Schema", t.Schema).
Str("Name", t.Name).
Int("Oid", int(t.Oid)).
Msg("cannot register array type for custom type")
}
continue

}
arrayTypeName := fmt.Sprintf("_%s", t.Name)
typeMap.RegisterType(&pgtype.Type{
Expand Down
Loading