EncodeRow is superceded by CompositeFields
This commit is contained in:
-19
@@ -433,25 +433,6 @@ func GetAssignToDstType(dst interface{}) (interface{}, bool) {
|
|||||||
return nil, false
|
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() {
|
func init() {
|
||||||
kindTypes = map[reflect.Kind]reflect.Type{
|
kindTypes = map[reflect.Kind]reflect.Type{
|
||||||
reflect.Bool: reflect.TypeOf(false),
|
reflect.Bool: reflect.TypeOf(false),
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func (src MyType) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) (newBuf []byte,
|
|||||||
b = pgtype.Text{Status: pgtype.Null}
|
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 {
|
func ptrS(s string) *string {
|
||||||
|
|||||||
Reference in New Issue
Block a user