mirror of https://github.com/jackc/pgx.git
check array just using len and remove imposible condition
parent
e5d321f920
commit
877111ceeb
|
@ -161,7 +161,7 @@ type derivedTypeInfo struct {
|
||||||
// The result of this call can be passed into RegisterTypes to complete the process.
|
// The result of this call can be passed into RegisterTypes to complete the process.
|
||||||
func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Type, error) {
|
func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Type, error) {
|
||||||
m := c.TypeMap()
|
m := c.TypeMap()
|
||||||
if typeNames == nil || len(typeNames) == 0 {
|
if len(typeNames) == 0 {
|
||||||
return nil, fmt.Errorf("No type names were supplied.")
|
return nil, fmt.Errorf("No type names were supplied.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,8 @@ func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Typ
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Unknown typtype %q was found while registering %q", ti.Typtype, ti.TypeName)
|
return nil, fmt.Errorf("Unknown typtype %q was found while registering %q", ti.Typtype, ti.TypeName)
|
||||||
}
|
}
|
||||||
if type_ != nil {
|
|
||||||
|
// the type_ is imposible to be null
|
||||||
m.RegisterType(type_)
|
m.RegisterType(type_)
|
||||||
if ti.NspName != "" {
|
if ti.NspName != "" {
|
||||||
nspType := &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}
|
||||||
|
@ -241,7 +242,6 @@ func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Typ
|
||||||
}
|
}
|
||||||
result = append(result, type_)
|
result = append(result, type_)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue