ignore unmapped values

When a name is not mapped then the field should not be updated. This is
a bit weird and maybe should throw an error, but at least we avoid
chaning columns that are not meant to be changed.
This commit is contained in:
Gibheer 2021-05-21 20:54:44 +02:00
parent f28b0d0ae3
commit 1696b6e15e
1 changed files with 3 additions and 0 deletions

View File

@ -80,6 +80,9 @@ func FieldMapToUpdate(fm types.FieldMap, nameMap map[string]string) (string, []i
i := 0
for key, val := range fm.Fields() {
if name, found := nameMap[key]; found {
if name == "" {
continue
}
i++
setClause = append(setClause, fmt.Sprintf("%s = $%d", name, i))
if val == "" {