diff --git a/structs/storage/article.go b/structs/storage/article.go index eea0b78..5c4192d 100644 --- a/structs/storage/article.go +++ b/structs/storage/article.go @@ -46,14 +46,13 @@ func (a *articleApi) Upsert(article v2.Article) error { } return nil }) - } func (a *articleApi) Update(article v2.Article, selects ...string) error { - if len(selects) > 0 { - selects = []string{"remark", "exclude"} + if len(selects) == 0 { + 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 diff --git a/structs/storage/article_test.go b/structs/storage/article_test.go index 843af14..4513f42 100644 --- a/structs/storage/article_test.go +++ b/structs/storage/article_test.go @@ -62,3 +62,9 @@ func TestUpsetArticle(t *testing.T) { t.Fatal(err) } } + +func TestArticleApi_Update(t *testing.T) { + db, _ := GetDevDB() + articleApi := NewArticleApi(db) + articleApi.Update(article) +}