Browse Source

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.
master
Gibheer 1 year ago
parent
commit
1696b6e15e
  1. 3
      query/query.go

3
query/query.go

@ -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 == "" {

Loading…
Cancel
Save