mirror of https://github.com/jackc/pgx.git
Merge branch 'aka-rider-fix-record-panic'
commit
da564d2801
|
@ -98,9 +98,10 @@ func (dst *Record) DecodeBinary(ci *ConnInfo, src []byte) error {
|
||||||
|
|
||||||
var binaryDecoder BinaryDecoder
|
var binaryDecoder BinaryDecoder
|
||||||
if dt, ok := ci.DataTypeForOID(fieldOID); ok {
|
if dt, ok := ci.DataTypeForOID(fieldOID); ok {
|
||||||
if binaryDecoder, ok = dt.Value.(BinaryDecoder); !ok {
|
binaryDecoder, _ = dt.Value.(BinaryDecoder)
|
||||||
return errors.Errorf("unknown oid while decoding record: %v", fieldOID)
|
|
||||||
}
|
}
|
||||||
|
if binaryDecoder == nil {
|
||||||
|
return errors.Errorf("unknown oid while decoding record: %v", fieldOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldBytes []byte
|
var fieldBytes []byte
|
||||||
|
|
|
@ -102,6 +102,28 @@ func TestRecordTranscode(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRecordWithUnknownOID(t *testing.T) {
|
||||||
|
conn := testutil.MustConnectPgx(t)
|
||||||
|
defer testutil.MustClose(t, conn)
|
||||||
|
|
||||||
|
_, err := conn.Exec(`drop type if exists floatrange;
|
||||||
|
|
||||||
|
create type floatrange as range (
|
||||||
|
subtype = float8,
|
||||||
|
subtype_diff = float8mi
|
||||||
|
);`)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer conn.Exec("drop type floatrange")
|
||||||
|
|
||||||
|
var result pgtype.Record
|
||||||
|
err = conn.QueryRow("select row('foo'::text, floatrange(1, 10), 'bar'::text)").Scan(&result)
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("expected error but none")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRecordAssignTo(t *testing.T) {
|
func TestRecordAssignTo(t *testing.T) {
|
||||||
var valueSlice []pgtype.Value
|
var valueSlice []pgtype.Value
|
||||||
var interfaceSlice []interface{}
|
var interfaceSlice []interface{}
|
||||||
|
|
Loading…
Reference in New Issue