2
0

Remove BinaryEncoder and TextEncoder

This commit is contained in:
Jack Christensen
2022-01-22 12:16:02 -06:00
parent 3a90c6c879
commit 4cf6dc9447
4 changed files with 18 additions and 162 deletions
+4 -23
View File
@@ -247,32 +247,13 @@ func (rows *connRows) Values() ([]interface{}, error) {
if dt, ok := rows.connInfo.DataTypeForOID(fd.DataTypeOID); ok {
if dt.Value != nil {
value := dt.Value
switch fd.Format {
case TextFormatCode:
if decoder, ok := value.(pgtype.TextDecoder); ok {
err := decoder.DecodeText(rows.connInfo, buf)
if err != nil {
rows.fatal(err)
}
values = append(values, decoder.(pgtype.Value).Get())
} else {
values = append(values, string(buf))
}
values = append(values, string(buf))
case BinaryFormatCode:
if decoder, ok := value.(pgtype.BinaryDecoder); ok {
err := decoder.DecodeBinary(rows.connInfo, buf)
if err != nil {
rows.fatal(err)
}
values = append(values, value.Get())
} else {
newBuf := make([]byte, len(buf))
copy(newBuf, buf)
values = append(values, newBuf)
}
newBuf := make([]byte, len(buf))
copy(newBuf, buf)
values = append(values, newBuf)
default:
rows.fatal(errors.New("Unknown format code"))
}