Skip to content

Commit

Permalink
fix(scan): array element is set to a zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Mar 11, 2024
1 parent e4e23d2 commit f6d9ee7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ func Scan(rows Rows, db *DB, mode ScanMode) {

if !update || reflectValue.Len() == 0 {
update = false
if !isArrayKind {
if isArrayKind {
for i := 0; i < reflectValue.Len(); i++ {
reflectValue.Index(i).Set(reflect.Zero(reflectValue.Index(i).Type()))
}
} else {
// 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))
Expand Down

0 comments on commit f6d9ee7

Please sign in to comment.