mirror of https://github.com/go-gorm/gorm.git
Fix data race problem when using Scan, close #3662
This commit is contained in:
parent
0aef8acc11
commit
db2630cb3a
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue