revert change in if

pull/2288/head
Felix Röhrich 2025-03-24 15:01:22 +01:00
parent 5c1fbf4806
commit 63422c7d6c
2 changed files with 6 additions and 3 deletions

View File

@ -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()

View File

@ -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)
})
}