Make receiver name of structField consistent

This commit is contained in:
David Zhang 2018-11-04 22:41:58 +08:00
parent 472c70caa4
commit 69e61e3e7f

View File

@ -91,31 +91,31 @@ func (s *StructField) TagSettingsDelete(key string) {
delete(s.TagSettings, key)
}
func (structField *StructField) clone() *StructField {
func (s *StructField) clone() *StructField {
clone := &StructField{
DBName: structField.DBName,
Name: structField.Name,
Names: structField.Names,
IsPrimaryKey: structField.IsPrimaryKey,
IsNormal: structField.IsNormal,
IsIgnored: structField.IsIgnored,
IsScanner: structField.IsScanner,
HasDefaultValue: structField.HasDefaultValue,
Tag: structField.Tag,
DBName: s.DBName,
Name: s.Name,
Names: s.Names,
IsPrimaryKey: s.IsPrimaryKey,
IsNormal: s.IsNormal,
IsIgnored: s.IsIgnored,
IsScanner: s.IsScanner,
HasDefaultValue: s.HasDefaultValue,
Tag: s.Tag,
TagSettings: map[string]string{},
Struct: structField.Struct,
IsForeignKey: structField.IsForeignKey,
Struct: s.Struct,
IsForeignKey: s.IsForeignKey,
}
if structField.Relationship != nil {
relationship := *structField.Relationship
if s.Relationship != nil {
relationship := *s.Relationship
clone.Relationship = &relationship
}
// copy the struct field tagSettings, they should be read-locked while they are copied
structField.tagSettingsLock.Lock()
defer structField.tagSettingsLock.Unlock()
for key, value := range structField.TagSettings {
s.tagSettingsLock.Lock()
defer s.tagSettingsLock.Unlock()
for key, value := range s.TagSettings {
clone.TagSettings[key] = value
}