diff --git a/structs/storage/article.go b/structs/storage/article.go index d441a2c..7f1d3d4 100644 --- a/structs/storage/article.go +++ b/structs/storage/article.go @@ -35,10 +35,15 @@ func (a *articleApi) Upsert(article v2.Article) error { }).Create(&article).Error; err != nil { return err } - if err := tx.Save(&article.Providers).Error; err != nil { - return fmt.Errorf("failed to save providers: %v", err) + if len(article.Providers) > 0 { + if err := tx.Save(&article.Providers).Error; err != nil { + return fmt.Errorf("failed to save providers: %v", err) + } } - return tx.Save(&article.Sellers).Error + if len(article.Sellers) > 0 { + return tx.Save(&article.Sellers).Error + } + return nil }) }