Skip to content

Commit

Permalink
fix(scan.go): reflect.MakeSlice passes in the reflect.Array type (#6880)
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito authored Mar 9, 2024
1 parent 9efae65 commit c4c9aa4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit c4c9aa4

Please sign in to comment.