Skip to content

Commit ed25214

Browse files
committed
fix: handle char(bpchar) as string
1 parent 9eb3fc8 commit ed25214

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func binaryDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) inter
9292

9393
func textDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) interface{} {
9494
switch typ {
95-
case oid.T_char, oid.T_varchar, oid.T_text:
95+
case oid.T_char, oid.T_bpchar, oid.T_varchar, oid.T_text:
9696
return string(s)
9797
case oid.T_bytea:
9898
b, err := parseBytea(s)

encode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func TestBinaryByteSliceToInt(t *testing.T) {
607607
func TestTextDecodeIntoString(t *testing.T) {
608608
input := []byte("hello world")
609609
want := string(input)
610-
for _, typ := range []oid.Oid{oid.T_char, oid.T_varchar, oid.T_text} {
610+
for _, typ := range []oid.Oid{oid.T_char, oid.T_bpchar, oid.T_varchar, oid.T_text} {
611611
got := decode(&parameterStatus{}, input, typ, formatText)
612612
if got != want {
613613
t.Errorf("invalid string decoding output for %T(%+v), got %v but expected %v", typ, typ, got, want)

0 commit comments

Comments
 (0)