Skip to content

Commit

Permalink
Fix skipping unknown type when silent is true (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsg authored Dec 6, 2024
1 parent 2c31433 commit fc27a6a
Showing 1 changed file with 20 additions and 15 deletions.
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{
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

0 comments on commit fc27a6a

Please sign in to comment.