mirror of https://github.com/jackc/pgx.git
Refactor Conn.LoadTypes by removing redundant check
parent
e5d321f920
commit
311f72afdc
|
@ -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.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,13 +169,7 @@ func (c *Conn) LoadTypes(ctx context.Context, typeNames []string) ([]*pgtype.Typ
|
||||||
// the SQL not support recent structures such as multirange
|
// the SQL not support recent structures such as multirange
|
||||||
serverVersion, _ := serverVersion(c)
|
serverVersion, _ := serverVersion(c)
|
||||||
sql := buildLoadDerivedTypesSQL(serverVersion, typeNames)
|
sql := buildLoadDerivedTypesSQL(serverVersion, typeNames)
|
||||||
var rows Rows
|
rows, err := c.Query(ctx, sql, QueryExecModeSimpleProtocol, typeNames)
|
||||||
var err error
|
|
||||||
if typeNames == nil {
|
|
||||||
rows, err = c.Query(ctx, sql, QueryExecModeSimpleProtocol)
|
|
||||||
} else {
|
|
||||||
rows, err = c.Query(ctx, sql, QueryExecModeSimpleProtocol, typeNames)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("While generating load types query: %w", err)
|
return nil, fmt.Errorf("While generating load types query: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue