From 36bdbd7cb105417f883270555f853b2cc17c43b5 Mon Sep 17 00:00:00 2001 From: Manni Wood Date: Sat, 12 Nov 2016 11:56:04 -0500 Subject: [PATCH] Parses actual return string ...but only handles aclitem[] size 1 --- values.go | 11 ++++++++++- values_test.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/values.go b/values.go index 0723189c..251671bc 100644 --- a/values.go +++ b/values.go @@ -3009,7 +3009,16 @@ func encodeAclItemSlice(w *WriteBuf, oid Oid, value []AclItem) error { // XXX: decodeAclItemArray; using text encoding, not binary func decodeAclItemArray(vr *ValueReader) []AclItem { - return []AclItem{"=r/postgres"} + if vr.Len() == -1 { + vr.Fatal(ProtocolError("Cannot decode null into []AclItem")) + return nil + } + + str := vr.ReadString(vr.Len()) + // remove the '{' at the front and the '}' at the end + str = str[1 : len(str)-1] + return []AclItem{AclItem(str)} + // return []AclItem{"=r/postgres"} } func encodeStringSlice(w *WriteBuf, oid Oid, slice []string) error { diff --git a/values_test.go b/values_test.go index 92ec01a6..326335e0 100644 --- a/values_test.go +++ b/values_test.go @@ -661,7 +661,7 @@ func TestAclArrayDecoding(t *testing.T) { &[]pgx.AclItem{}, func(t *testing.T, query, scan interface{}) { if !reflect.DeepEqual(query, *(scan.(*[]pgx.AclItem))) { - t.Errorf("failed to encode aclitem[]") + t.Errorf("failed to encode aclitem[]\n EXPECTED: %v\n ACTUAL: %v", query, *(scan.(*[]pgx.AclItem))) } }, },