optimization logic
This commit is contained in:
parent
a458bbb6a1
commit
adf114a7fc
5
scan.go
5
scan.go
@ -311,9 +311,8 @@ func Scan(rows Rows, db *DB, mode ScanMode) {
|
|||||||
db.scanIntoStruct(rows, elem, values, fields, joinFields)
|
db.scanIntoStruct(rows, elem, values, fields, joinFields)
|
||||||
|
|
||||||
if !update {
|
if !update {
|
||||||
rows := int(db.RowsAffected)
|
|
||||||
// array index is out of bounds, exits the for loop
|
// array index is out of bounds, exits the for loop
|
||||||
if isArrayKind && reflectValue.Len() < rows {
|
if isArrayKind && reflectValue.Len() < int(db.RowsAffected) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +320,7 @@ func Scan(rows Rows, db *DB, mode ScanMode) {
|
|||||||
elem = elem.Elem()
|
elem = elem.Elem()
|
||||||
}
|
}
|
||||||
if isArrayKind {
|
if isArrayKind {
|
||||||
reflectValue.Index(rows - 1).Set(elem)
|
reflectValue.Index(int(db.RowsAffected - 1)).Set(elem)
|
||||||
} else {
|
} else {
|
||||||
reflectValue = reflect.Append(reflectValue, elem)
|
reflectValue = reflect.Append(reflectValue, elem)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user