File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ type scanPlanJSONToJSONUnmarshal struct {
197
197
}
198
198
199
199
func (s * scanPlanJSONToJSONUnmarshal ) Scan (src []byte , dst any ) error {
200
- if src == nil || string ( src ) == "null" {
200
+ if src == nil {
201
201
dstValue := reflect .ValueOf (dst )
202
202
if dstValue .Kind () == reflect .Ptr {
203
203
el := dstValue .Elem ()
Original file line number Diff line number Diff line change @@ -335,8 +335,7 @@ func TestJSONCodecScanNull(t *testing.T) {
335
335
require .Contains (t , err .Error (), "cannot scan NULL into *struct {}" )
336
336
337
337
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 )
340
339
341
340
var destPointer * struct {}
342
341
err = conn .QueryRow (ctx , "select null::jsonb" ).Scan (& destPointer )
@@ -346,6 +345,10 @@ func TestJSONCodecScanNull(t *testing.T) {
346
345
err = conn .QueryRow (ctx , "select 'null'::jsonb" ).Scan (& destPointer )
347
346
require .NoError (t , err )
348
347
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 )
349
352
})
350
353
}
351
354
You can’t perform that action at this time.
0 commit comments