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,13 +207,13 @@ 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
|
||||||
// parse relations for unidentified fields
|
for _, field := range schema.Fields {
|
||||||
for _, field := range schema.Fields {
|
if field.DataType == "" && field.Creatable {
|
||||||
if field.DataType == "" && field.Creatable {
|
if schema.parseRelation(field); schema.err != nil {
|
||||||
if schema.parseRelation(field); schema.err != nil {
|
return schema, schema.err
|
||||||
return schema, schema.err
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue