Fix data race problem when using Scan, close #3662

This commit is contained in:
Jinzhu 2020-10-22 17:32:39 +08:00
parent 0aef8acc11
commit db2630cb3a
1 changed files with 6 additions and 2 deletions

View File

@ -365,9 +365,13 @@ func (db *DB) Rows() (*sql.Rows, error) {
// Scan scan value to a struct
func (db *DB) Scan(dest interface{}) (tx *DB) {
currentLogger, newLogger := db.Logger, logger.Recorder.New()
config := *db.Config
currentLogger, newLogger := config.Logger, logger.Recorder.New()
config.Logger = newLogger
tx = db.getInstance()
tx.Logger = newLogger
tx.Config = &config
if rows, err := tx.Rows(); err != nil {
tx.AddError(err)
} else {