Special case the underlying type of []byte
Underlying types were already tried. But []byte is not a normal underlying type. It is a slice. But since is can be treated as a scalar instead of an array / slice we need to special case it. https://github.com/jackc/pgx/issues/1763
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -417,6 +418,14 @@ func TestMapEncodeByteSliceIntoUnregisteredTypeTextFormat(t *testing.T) {
|
||||
require.Equal(t, []byte(`\x00010203`), buf)
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/1763
|
||||
func TestMapEncodeNamedTypeOfByteSliceIntoTextTextFormat(t *testing.T) {
|
||||
m := pgtype.NewMap()
|
||||
buf, err := m.Encode(pgtype.TextOID, pgtype.TextFormatCode, json.RawMessage(`{"foo": "bar"}`), nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte(`{"foo": "bar"}`), buf)
|
||||
}
|
||||
|
||||
// https://github.com/jackc/pgx/issues/1326
|
||||
func TestMapScanPointerToRenamedType(t *testing.T) {
|
||||
srcBuf := []byte("foo")
|
||||
|
||||
Reference in New Issue
Block a user