2
0

EncodeRow is superceded by CompositeFields

This commit is contained in:
Jack Christensen
2020-05-12 15:51:27 -05:00
parent 506ea36835
commit 9a3923b6e0
2 changed files with 1 additions and 20 deletions
-19
View File
@@ -433,25 +433,6 @@ func GetAssignToDstType(dst interface{}) (interface{}, bool) {
return nil, false
}
// EncodeRow builds a binary representation of row values (row(), composite types)
func EncodeRow(ci *ConnInfo, buf []byte, fields ...Value) (newBuf []byte, err error) {
b := NewCompositeBinaryBuilder(ci, buf)
for _, f := range fields {
dt, ok := ci.DataTypeForValue(f)
if !ok {
return nil, errors.Errorf("Unknown OID for %s", f)
}
binaryEncoder, ok := f.(BinaryEncoder)
if !ok {
return nil, errors.Errorf("record field doesn't implement binary encoding: %s", reflect.TypeOf(f).Name())
}
b.AppendEncoder(dt.OID, binaryEncoder)
}
return b.Finish()
}
func init() {
kindTypes = map[reflect.Kind]reflect.Type{
reflect.Bool: reflect.TypeOf(false),
+1 -1
View File
@@ -36,7 +36,7 @@ func (src MyType) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) (newBuf []byte,
b = pgtype.Text{Status: pgtype.Null}
}
return pgtype.EncodeRow(ci, buf, &a, &b)
return (pgtype.CompositeFields{&a, &b}).EncodeBinary(ci, buf)
}
func ptrS(s string) *string {