mirror of
https://github.com/jackc/pgx.git
synced 2025-05-28 02:02:52 +00:00
Remove convertToBoolForEncode
This commit is contained in:
parent
6cb3439492
commit
6be0c3f6b2
@ -236,42 +236,6 @@ func (c BoolCodec) DecodeValue(ci *ConnInfo, oid uint32, format int16, src []byt
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func convertToBoolForEncode(v interface{}) (b bool, valid bool, err error) {
|
||||
if v == nil {
|
||||
return false, false, nil
|
||||
}
|
||||
|
||||
switch v := v.(type) {
|
||||
case bool:
|
||||
return v, true, nil
|
||||
case *bool:
|
||||
if v == nil {
|
||||
return false, false, nil
|
||||
}
|
||||
return *v, true, nil
|
||||
case string:
|
||||
bb, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return false, false, err
|
||||
}
|
||||
return bb, true, nil
|
||||
case *string:
|
||||
if v == nil {
|
||||
return false, false, nil
|
||||
}
|
||||
bb, err := strconv.ParseBool(*v)
|
||||
if err != nil {
|
||||
return false, false, err
|
||||
}
|
||||
return bb, true, nil
|
||||
default:
|
||||
if originalvalue, ok := underlyingBoolType(v); ok {
|
||||
return convertToBoolForEncode(originalvalue)
|
||||
}
|
||||
return false, false, fmt.Errorf("cannot convert %v to bool", v)
|
||||
}
|
||||
}
|
||||
|
||||
type scanPlanBinaryBoolToBool struct{}
|
||||
|
||||
func (scanPlanBinaryBoolToBool) Scan(ci *ConnInfo, oid uint32, formatCode int16, src []byte, dst interface{}) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user