diff --git a/scan.go b/scan.go index 360ed8b9..119049c6 100644 --- a/scan.go +++ b/scan.go @@ -225,7 +225,8 @@ func Scan(rows *sql.Rows, db *DB, mode ScanMode) { case reflect.Slice, reflect.Array: var elem reflect.Value - if !update && reflectValue.Len() != 0 { + if !update || reflectValue.Len() == 0 { + update = false db.Statement.ReflectValue.Set(reflect.MakeSlice(reflectValue.Type(), 0, 20)) } diff --git a/tests/go.mod b/tests/go.mod index ab3ef898..52781a8b 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,7 +6,7 @@ require ( github.com/google/uuid v1.3.0 github.com/jinzhu/now v1.1.2 github.com/lib/pq v1.10.3 - gorm.io/driver/mysql v1.1.2 + gorm.io/driver/mysql v1.1.3 gorm.io/driver/postgres v1.2.1 gorm.io/driver/sqlite v1.2.2 gorm.io/driver/sqlserver v1.1.2