Fix JSON scan not completely overwriting destination
See https://github.com/jackc/pgtype/pull/185 for original report in pgx v4 / pgtype.
This commit is contained in:
@@ -134,6 +134,9 @@ func (scanPlanJSONToJSONUnmarshal) Scan(src []byte, dst any) error {
|
||||
return fmt.Errorf("cannot scan NULL into %T", dst)
|
||||
}
|
||||
|
||||
elem := reflect.ValueOf(dst).Elem()
|
||||
elem.Set(reflect.Zero(elem.Type()))
|
||||
|
||||
return json.Unmarshal(src, dst)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user