mirror of https://github.com/go-gorm/gorm.git
fix(scan.go): reflect.MakeSlice passes in the reflect.Array type (#6880)
This commit is contained in:
parent
9efae659cb
commit
c4c9aa45e3
4
scan.go
4
scan.go
|
@ -274,14 +274,16 @@ func Scan(rows Rows, db *DB, mode ScanMode) {
|
||||||
|
|
||||||
if !update || reflectValue.Len() == 0 {
|
if !update || reflectValue.Len() == 0 {
|
||||||
update = false
|
update = false
|
||||||
|
if !isArrayKind {
|
||||||
// if the slice cap is externally initialized, the externally initialized slice is directly used here
|
// if the slice cap is externally initialized, the externally initialized slice is directly used here
|
||||||
if reflectValue.Cap() == 0 {
|
if reflectValue.Cap() == 0 {
|
||||||
db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20))
|
db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20))
|
||||||
} else if !isArrayKind {
|
} else {
|
||||||
reflectValue.SetLen(0)
|
reflectValue.SetLen(0)
|
||||||
db.Statement.ReflectValue.Set(reflectValue)
|
db.Statement.ReflectValue.Set(reflectValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for initialized || rows.Next() {
|
for initialized || rows.Next() {
|
||||||
BEGIN:
|
BEGIN:
|
||||||
|
|
Loading…
Reference in New Issue