From a7975f7ba771cee0713b3eefd2f9ada368d37d1e Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Fri, 6 Dec 2024 17:42:17 +0000 Subject: [PATCH 1/3] Fix skipping unkknown type when silent is true --- pkg/toolkit/types.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/toolkit/types.go b/pkg/toolkit/types.go index 2a41e9e6..02a2f882 100644 --- a/pkg/toolkit/types.go +++ b/pkg/toolkit/types.go @@ -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{ From 3e2f7109509199c8df400696f9d9689ca4536cf0 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Fri, 6 Dec 2024 21:31:22 +0000 Subject: [PATCH 2/3] Fix also for array type --- pkg/toolkit/types.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/toolkit/types.go b/pkg/toolkit/types.go index 02a2f882..c9611829 100644 --- a/pkg/toolkit/types.go +++ b/pkg/toolkit/types.go @@ -148,14 +148,16 @@ 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") - continue + 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{ From 6fbf6f3b484ed2f4ebc52240403f8613d3610eb8 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Fri, 6 Dec 2024 21:52:26 +0000 Subject: [PATCH 3/3] fix --- pkg/toolkit/types.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/toolkit/types.go b/pkg/toolkit/types.go index c9611829..f67ae858 100644 --- a/pkg/toolkit/types.go +++ b/pkg/toolkit/types.go @@ -156,8 +156,9 @@ func TryRegisterCustomTypes(typeMap *pgtype.Map, types []*Type, silent bool) { Str("Name", t.Name). Int("Oid", int(t.Oid)). Msg("cannot register array type for custom type") - continue } + continue + } arrayTypeName := fmt.Sprintf("_%s", t.Name) typeMap.RegisterType(&pgtype.Type{