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) | ||||
| 
 | ||||
| 	// parse relations for unidentified fields
 | ||||
| 	for _, field := range schema.Fields { | ||||
| 		if field.DataType == "" && field.Creatable { | ||||
| 			if schema.parseRelation(field); schema.err != nil { | ||||
| 				return schema, schema.err | ||||
| 	if _, loaded := cacheStore.LoadOrStore(modelType, schema); !loaded { | ||||
| 		// parse relations for unidentified fields
 | ||||
| 		for _, field := range schema.Fields { | ||||
| 			if field.DataType == "" && field.Creatable { | ||||
| 				if schema.parseRelation(field); schema.err != nil { | ||||
| 					return schema, schema.err | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jinzhu
						Jinzhu