From 562f98ddaf9862afc17d725a7585a8ebb493df61 Mon Sep 17 00:00:00 2001 From: gengleiming <244277947@qq.com> Date: Mon, 26 Sep 2022 14:45:58 +0800 Subject: [PATCH] bug: user update by multifields, param need '...' (#1170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bug: 多字段更新用户时,参数作为slice接受,需要拆包之后再往下传入。该bug导致user.Update方法只能成功更新第一个参数对应的字段 --- src/models/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/user.go b/src/models/user.go index e6ea75a5..c7b7846f 100644 --- a/src/models/user.go +++ b/src/models/user.go @@ -95,7 +95,7 @@ func (u *User) Update(selectField interface{}, selectFields ...interface{}) erro return err } - return DB().Model(u).Select(selectField, selectFields).Updates(u).Error + return DB().Model(u).Select(selectField, selectFields...).Updates(u).Error } func (u *User) UpdateAllFields() error {