From fe77d2eb9da20945d1fdabdd5ef49fa4aaf593b5 Mon Sep 17 00:00:00 2001 From: demoManito <1430482733@qq.com> Date: Thu, 7 Mar 2024 14:20:12 +0800 Subject: [PATCH] fix(scan.go): reflect.MakeSlice passes in the reflect.Array type --- scan.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scan.go b/scan.go index 736db4d3..54cd6769 100644 --- a/scan.go +++ b/scan.go @@ -274,12 +274,14 @@ func Scan(rows Rows, db *DB, mode ScanMode) { if !update || reflectValue.Len() == 0 { update = false - // if the slice cap is externally initialized, the externally initialized slice is directly used here - if reflectValue.Cap() == 0 { - db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20)) - } else if !isArrayKind { - reflectValue.SetLen(0) - db.Statement.ReflectValue.Set(reflectValue) + if !isArrayKind { + // if the slice cap is externally initialized, the externally initialized slice is directly used here + if reflectValue.Cap() == 0 { + db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20)) + } else { + reflectValue.SetLen(0) + db.Statement.ReflectValue.Set(reflectValue) + } } }