Skip to content

Commit

Permalink
only add update if it has a set clause
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDubelman committed Oct 23, 2024
1 parent 35df459 commit 0a7dece
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,19 @@ func (t table) syncTarget(
pkSet[pk] = struct{}{}
}

var hasUpdate bool
for i, col := range t.columns {
if _, ok := pkSet[col]; ok {
continue // Skip updating primary key columns
}

update = update.Set(col, val[i])
hasUpdate = true
}

updates = append(updates, update)
if hasUpdate {
updates = append(updates, update)
}
}
}

Expand Down

0 comments on commit 0a7dece

Please sign in to comment.