Skip to content

Commit

Permalink
Refactor Conn.LoadTypes by removing redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Dec 24, 2024
1 parent e5d321f commit 311f72a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions derived_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,15 @@ 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.")
}

// Disregard server version errors. This will result in
// the SQL not support recent structures such as multirange
serverVersion, _ := serverVersion(c)
sql := buildLoadDerivedTypesSQL(serverVersion, typeNames)
var rows Rows
var err error
if typeNames == nil {
rows, err = c.Query(ctx, sql, QueryExecModeSimpleProtocol)
} else {
rows, err = c.Query(ctx, sql, QueryExecModeSimpleProtocol, typeNames)
}
rows, err := c.Query(ctx, sql, QueryExecModeSimpleProtocol, typeNames)
if err != nil {
return nil, fmt.Errorf("While generating load types query: %w", err)
}
Expand Down

0 comments on commit 311f72a

Please sign in to comment.