From 8417729f4be71d92e73b297efc1ede68eb561e9b Mon Sep 17 00:00:00 2001 From: Gerhard Gruber Date: Thu, 21 Oct 2021 19:52:23 +0200 Subject: [PATCH] Update issue with UpdateFields When calling UpdateFields on a DB, it modified the DB and the field names persisted --- expression_ext.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/expression_ext.go b/expression_ext.go index 137b1b4a..a2b7da77 100644 --- a/expression_ext.go +++ b/expression_ext.go @@ -441,13 +441,13 @@ func (db *DB) UpdateFields(fields ...string) *DB { sets[db.C(db.Value, field)] = m.FieldByName(field).Interface() } - return db.Set("gorm:save_associations", false).Update(sets) + return db.clone().Set("gorm:save_associations", false).Update(sets) } func (db *DB) SelectFields(fields ...string) *DB { selects := strings.Join(fields, ", ") - return db.Select(selects) + return db.clone().Select(selects) } func (e *expr) Intersect(e2 *expr) *expr {