feature (db): Add support for multi-column PKs (#1658)
This commit is contained in:
9 files changed
+526
-69
No files matched your search
@@ -46,6 +46,16 @@ func UpdateFields(i interface{}, fieldMaskPaths []string, setToNullPaths []strin
|
||||
val := reflect.Indirect(reflect.ValueOf(i))
|
||||
structTyp := val.Type()
|
||||
for i := 0; i < structTyp.NumField(); i++ {
|
||||
if f, ok := maskPaths[strings.ToUpper(structTyp.Field(i).Name)]; ok {
|
||||
updateFields[f] = val.Field(i).Interface()
|
||||
found[strings.ToUpper(f)] = struct{}{}
|
||||
continue
|
||||
}
|
||||
if f, ok := nullPaths[strings.ToUpper(structTyp.Field(i).Name)]; ok {
|
||||
updateFields[f] = gorm.Expr("NULL")
|
||||
found[strings.ToUpper(f)] = struct{}{}
|
||||
continue
|
||||
}
|
||||
kind := structTyp.Field(i).Type.Kind()
|
||||
if kind == reflect.Struct || kind == reflect.Ptr {
|
||||
embType := structTyp.Field(i).Type
|
||||
@@ -76,14 +86,6 @@ func UpdateFields(i interface{}, fieldMaskPaths []string, setToNullPaths []strin
|
||||
continue
|
||||
}
|
||||
}
|
||||
if f, ok := maskPaths[strings.ToUpper(structTyp.Field(i).Name)]; ok {
|
||||
updateFields[f] = val.Field(i).Interface()
|
||||
found[strings.ToUpper(f)] = struct{}{}
|
||||
}
|
||||
if f, ok := nullPaths[strings.ToUpper(structTyp.Field(i).Name)]; ok {
|
||||
updateFields[f] = gorm.Expr("NULL")
|
||||
found[strings.ToUpper(f)] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
if missing := findMissingPaths(setToNullPaths, found); len(missing) != 0 {
|
||||
|
||||
Reference in new issue
Block a user