diff --git a/CHANGELOG.md b/CHANGELOG.md index 04aef656..094dcb58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,8 +30,11 @@ newer. Previously PostgreSQL 8.4 and newer were supported. - Don't set extra_float_digits ([#1212]). +- Decode bpchar into a string ([#949]). + [#595]: https://github.com/lib/pq/pull/595 [#745]: https://github.com/lib/pq/pull/745 +[#949]: https://github.com/lib/pq/pull/949 [#1125]: https://github.com/lib/pq/pull/1125 [#1129]: https://github.com/lib/pq/pull/1129 [#1133]: https://github.com/lib/pq/pull/1133 diff --git a/encode.go b/encode.go index 4ab82dd1..08c73023 100644 --- a/encode.go +++ b/encode.go @@ -95,7 +95,7 @@ func binaryDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) any { func textDecode(parameterStatus *parameterStatus, s []byte, typ oid.Oid) any { switch typ { - case oid.T_char, oid.T_varchar, oid.T_text: + case oid.T_char, oid.T_bpchar, oid.T_varchar, oid.T_text: return string(s) case oid.T_bytea: b, err := parseBytea(s) diff --git a/encode_test.go b/encode_test.go index b1ff08ec..1c7de04a 100644 --- a/encode_test.go +++ b/encode_test.go @@ -691,7 +691,7 @@ func TestBinaryByteSliceToInt(t *testing.T) { func TestTextDecodeIntoString(t *testing.T) { input := []byte("hello world") want := string(input) - for _, typ := range []oid.Oid{oid.T_char, oid.T_varchar, oid.T_text} { + for _, typ := range []oid.Oid{oid.T_char, oid.T_bpchar, oid.T_varchar, oid.T_text} { got := decode(¶meterStatus{}, input, typ, formatText) if got != want { t.Errorf("invalid string decoding output for %T(%+v), got %v but expected %v", typ, typ, got, want)