Skip to content

Commit c4c9aa4

Browse files
authored
fix(scan.go): reflect.MakeSlice passes in the reflect.Array type (#6880)
1 parent 9efae65 commit c4c9aa4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

scan.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ func Scan(rows Rows, db *DB, mode ScanMode) {
274274

275275
if !update || reflectValue.Len() == 0 {
276276
update = false
277-
// if the slice cap is externally initialized, the externally initialized slice is directly used here
278-
if reflectValue.Cap() == 0 {
279-
db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20))
280-
} else if !isArrayKind {
281-
reflectValue.SetLen(0)
282-
db.Statement.ReflectValue.Set(reflectValue)
277+
if !isArrayKind {
278+
// if the slice cap is externally initialized, the externally initialized slice is directly used here
279+
if reflectValue.Cap() == 0 {
280+
db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20))
281+
} else {
282+
reflectValue.SetLen(0)
283+
db.Statement.ReflectValue.Set(reflectValue)
284+
}
283285
}
284286
}
285287

0 commit comments

Comments
 (0)