diff --git a/pgtype/convert.go b/pgtype/convert.go index 4eb8014a..7fddeaa8 100644 --- a/pgtype/convert.go +++ b/pgtype/convert.go @@ -64,6 +64,9 @@ func underlyingNumberType(val any) (any, bool) { case reflect.String: convVal := refVal.String() return convVal, reflect.TypeOf(convVal) != refVal.Type() + case reflect.Bool: + convVal := refVal.Bool() + return convVal, reflect.TypeOf(convVal) != refVal.Type() } return nil, false diff --git a/pgtype/pgtype.go b/pgtype/pgtype.go index 21ec179a..05f22a8c 100644 --- a/pgtype/pgtype.go +++ b/pgtype/pgtype.go @@ -666,6 +666,7 @@ var elemKindToPointerTypes map[reflect.Kind]reflect.Type = map[reflect.Kind]refl reflect.Float32: reflect.TypeOf(new(float32)), reflect.Float64: reflect.TypeOf(new(float64)), reflect.String: reflect.TypeOf(new(string)), + reflect.Bool: reflect.TypeOf(new(bool)), } type underlyingTypeScanPlan struct { diff --git a/values_test.go b/values_test.go index 658d0ce8..854fe279 100644 --- a/values_test.go +++ b/values_test.go @@ -881,6 +881,7 @@ func TestEncodeTypeRename(t *testing.T) { conn.TypeMap().RegisterDefaultPgType(inUint32, "int8") conn.TypeMap().RegisterDefaultPgType(inUint64, "int8") conn.TypeMap().RegisterDefaultPgType(inString, "text") + conn.TypeMap().RegisterDefaultPgType(inBool, "bool") err := conn.QueryRow(context.Background(), "select $1::int, $2::int, $3::int2, $4::int4, $5::int8, $6::int, $7::int, $8::int, $9::int, $10::int, $11::text, $12::bool", inInt, inInt8, inInt16, inInt32, inInt64, inUint, inUint8, inUint16, inUint32, inUint64, inString, inBool,