Skip to content

Commit

Permalink
Merge pull request #2203 from martinyonatann/chore/check-array-and-re…
Browse files Browse the repository at this point in the history
…move-imposible-condition

check array just using `len` and remove `imposible condition`
  • Loading branch information
jackc authored Dec 24, 2024
2 parents 473a241 + 877111c commit f7c3d19
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions derived_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ type derivedTypeInfo struct {
// 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) {
m := c.TypeMap()
if typeNames == nil || len(typeNames) == 0 {
if len(typeNames) == 0 {
return nil, fmt.Errorf("No type names were supplied.")
}

Expand Down Expand Up @@ -232,15 +232,15 @@ func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Typ
default:
return nil, fmt.Errorf("Unknown typtype %q was found while registering %q", ti.Typtype, ti.TypeName)
}
if type_ != nil {
m.RegisterType(type_)
if ti.NspName != "" {
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_)

// the type_ is imposible to be null
m.RegisterType(type_)
if ti.NspName != "" {
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_)
}
return result, nil
}
Expand Down

0 comments on commit f7c3d19

Please sign in to comment.