Parses actual return string

...but only handles aclitem[] size 1
pull/210/head
Manni Wood 2016-11-12 11:56:04 -05:00
parent a80ef6d35f
commit 36bdbd7cb1
2 changed files with 11 additions and 2 deletions

View File

@ -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 {

View File

@ -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)))
}
},
},