mirror of https://github.com/go-gorm/gorm.git
Fix concurrent map writes, close #3126
This commit is contained in:
parent
c091cd6aa4
commit
bc3728a18f
|
@ -207,8 +207,7 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
|
|||
}
|
||||
}
|
||||
|
||||
cacheStore.Store(modelType, schema)
|
||||
|
||||
if _, loaded := cacheStore.LoadOrStore(modelType, schema); !loaded {
|
||||
// parse relations for unidentified fields
|
||||
for _, field := range schema.Fields {
|
||||
if field.DataType == "" && field.Creatable {
|
||||
|
@ -217,6 +216,7 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return schema, schema.err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue