feat 修复article update select没生效的bug
This commit is contained in:
parent
a44474b191
commit
d24fecebdb
@ -46,14 +46,13 @@ func (a *articleApi) Upsert(article v2.Article) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *articleApi) Update(article v2.Article, selects ...string) error {
|
func (a *articleApi) Update(article v2.Article, selects ...string) error {
|
||||||
if len(selects) > 0 {
|
if len(selects) == 0 {
|
||||||
selects = []string{"remark", "exclude"}
|
selects = []string{"Remark", "Exclude"}
|
||||||
}
|
}
|
||||||
return a.db.Debug().Select(selects).Updates(article).Error
|
return a.db.Model(&article).Select(selects).Omit(clause.Associations).Updates(article).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************Find和List
|
// ******************Find和List
|
||||||
|
@ -62,3 +62,9 @@ func TestUpsetArticle(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArticleApi_Update(t *testing.T) {
|
||||||
|
db, _ := GetDevDB()
|
||||||
|
articleApi := NewArticleApi(db)
|
||||||
|
articleApi.Update(article)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user