Skip to content

Commit

Permalink
Fix bug relating to reuse of types
Browse files Browse the repository at this point in the history
When `LoadTypes` is being called, it does not include the
namespace-qualified types in its result. While these namespaces are
visible to `LoadTypes` itself, `RegisterTypes` will not recognise this
form of the types, only allowing them to be used if they are on the
schema path, and referred to without their namespace component.
  • Loading branch information
nicois committed Jul 7, 2024
1 parent 161ce73 commit 65b120f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion derived_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Typ
if type_ != nil {
m.RegisterType(type_)
if ti.NspName != "" {
m.RegisterType(&pgtype.Type{Name: ti.NspName + "." + type_.Name, OID: type_.OID, Codec: type_.Codec})
nspType := &pgtype.Type{Name: ti.NspName + "." + type_.Name, OID: type_.OID, Codec: type_.Codec}
m.RegisterType(nspType)
result = append(result, nspType)
}
result = append(result, type_)
}
Expand Down

0 comments on commit 65b120f

Please sign in to comment.