diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go index 75a0e8d65..0abb06b44 100644 --- a/pkg/common/db/relation/friend_request_model.go +++ b/pkg/common/db/relation/friend_request_model.go @@ -73,6 +73,7 @@ func (f *FriendRequestGorm) UpdateByMap( func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { return utils.Wrap( f.db(ctx). + Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID). Updates(friendRequest). Error, "", diff --git a/pkg/common/db/relation/meta_db.go b/pkg/common/db/relation/meta_db.go index 60e4a5464..6ab980120 100644 --- a/pkg/common/db/relation/meta_db.go +++ b/pkg/common/db/relation/meta_db.go @@ -33,5 +33,6 @@ func NewMetaDB(db *gorm.DB, table any) *MetaDB { } func (g *MetaDB) db(ctx context.Context) *gorm.DB { - return g.DB.WithContext(ctx).Model(g.table) + db := g.DB.WithContext(ctx).Model(g.table) + return db }