From f28d49e55e8e43d771304571878df4207669e819 Mon Sep 17 00:00:00 2001 From: jakezhu9 Date: Sun, 5 Mar 2023 13:35:27 +0800 Subject: [PATCH] fix: allow global update when clear action logs --- service/impl/log.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service/impl/log.go b/service/impl/log.go index 92331d8..281d30d 100644 --- a/service/impl/log.go +++ b/service/impl/log.go @@ -2,6 +2,7 @@ package impl import ( "context" + "gorm.io/gorm" "github.com/go-sonic/sonic/dal" "github.com/go-sonic/sonic/model/dto" @@ -18,7 +19,7 @@ func NewLogService() service.LogService { func (l *logServiceImpl) Clear(ctx context.Context) error { logDAL := dal.GetQueryByCtx(ctx).Log - _, err := logDAL.WithContext(ctx).Delete() + _, err := logDAL.WithContext(ctx).Session(&gorm.Session{AllowGlobalUpdate: true}).Delete() if err != nil { return WrapDBErr(err) }