File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ type scanPlanJSONToJSONUnmarshal struct {
197197}
198198
199199func (s * scanPlanJSONToJSONUnmarshal ) Scan (src []byte , dst any ) error {
200- if src == nil || string ( src ) == "null" {
200+ if src == nil {
201201 dstValue := reflect .ValueOf (dst )
202202 if dstValue .Kind () == reflect .Ptr {
203203 el := dstValue .Elem ()
Original file line number Diff line number Diff line change @@ -335,8 +335,7 @@ func TestJSONCodecScanNull(t *testing.T) {
335335 require .Contains (t , err .Error (), "cannot scan NULL into *struct {}" )
336336
337337 err = conn .QueryRow (ctx , "select 'null'::jsonb" ).Scan (& dest )
338- require .Error (t , err )
339- require .Contains (t , err .Error (), "cannot scan NULL into *struct {}" )
338+ require .NoError (t , err )
340339
341340 var destPointer * struct {}
342341 err = conn .QueryRow (ctx , "select null::jsonb" ).Scan (& destPointer )
@@ -346,6 +345,10 @@ func TestJSONCodecScanNull(t *testing.T) {
346345 err = conn .QueryRow (ctx , "select 'null'::jsonb" ).Scan (& destPointer )
347346 require .NoError (t , err )
348347 require .Nil (t , destPointer )
348+
349+ var raw json.RawMessage
350+ require .NoError (t , conn .QueryRow (ctx , "select 'null'::jsonb" ).Scan (& raw ))
351+ require .Equal (t , json .RawMessage ("null" ), raw )
349352 })
350353}
351354
You can’t perform that action at this time.
0 commit comments