Skip to content

Commit f7c3d19

Browse files
authored
Merge pull request #2203 from martinyonatann/chore/check-array-and-remove-imposible-condition
check array just using `len` and remove `imposible condition`
2 parents 473a241 + 877111c commit f7c3d19

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

derived_types.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ type derivedTypeInfo struct {
161161
// The result of this call can be passed into RegisterTypes to complete the process.
162162
func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Type, error) {
163163
m := c.TypeMap()
164-
if typeNames == nil || len(typeNames) == 0 {
164+
if len(typeNames) == 0 {
165165
return nil, fmt.Errorf("No type names were supplied.")
166166
}
167167

@@ -232,15 +232,15 @@ func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Typ
232232
default:
233233
return nil, fmt.Errorf("Unknown typtype %q was found while registering %q", ti.Typtype, ti.TypeName)
234234
}
235-
if type_ != nil {
236-
m.RegisterType(type_)
237-
if ti.NspName != "" {
238-
nspType := &pgtype.Type{Name: ti.NspName + "." + type_.Name, OID: type_.OID, Codec: type_.Codec}
239-
m.RegisterType(nspType)
240-
result = append(result, nspType)
241-
}
242-
result = append(result, type_)
235+
236+
// the type_ is imposible to be null
237+
m.RegisterType(type_)
238+
if ti.NspName != "" {
239+
nspType := &pgtype.Type{Name: ti.NspName + "." + type_.Name, OID: type_.OID, Codec: type_.Codec}
240+
m.RegisterType(nspType)
241+
result = append(result, nspType)
243242
}
243+
result = append(result, type_)
244244
}
245245
return result, nil
246246
}

0 commit comments

Comments
 (0)