mirror of https://github.com/jackc/pgx.git
revert change in if
parent
5c1fbf4806
commit
63422c7d6c
|
@ -197,7 +197,7 @@ type scanPlanJSONToJSONUnmarshal struct {
|
|||
}
|
||||
|
||||
func (s *scanPlanJSONToJSONUnmarshal) Scan(src []byte, dst any) error {
|
||||
if src == nil || string(src) == "null" {
|
||||
if src == nil {
|
||||
dstValue := reflect.ValueOf(dst)
|
||||
if dstValue.Kind() == reflect.Ptr {
|
||||
el := dstValue.Elem()
|
||||
|
|
|
@ -335,8 +335,7 @@ func TestJSONCodecScanNull(t *testing.T) {
|
|||
require.Contains(t, err.Error(), "cannot scan NULL into *struct {}")
|
||||
|
||||
err = conn.QueryRow(ctx, "select 'null'::jsonb").Scan(&dest)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "cannot scan NULL into *struct {}")
|
||||
require.NoError(t, err)
|
||||
|
||||
var destPointer *struct{}
|
||||
err = conn.QueryRow(ctx, "select null::jsonb").Scan(&destPointer)
|
||||
|
@ -346,6 +345,10 @@ func TestJSONCodecScanNull(t *testing.T) {
|
|||
err = conn.QueryRow(ctx, "select 'null'::jsonb").Scan(&destPointer)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, destPointer)
|
||||
|
||||
var raw json.RawMessage
|
||||
require.NoError(t, conn.QueryRow(ctx, "select 'null'::jsonb").Scan(&raw))
|
||||
require.Equal(t, json.RawMessage("null"), raw)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue