diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-02-23 15:11:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-23 22:11:56 +0800 |
commit | 0ae1ed749dd6581379b7ccf483d66051869b52d7 (patch) | |
tree | 0522d4888f51b9056e55a93dcb5bd46f2726ef2f /models/db/context.go | |
parent | 3adfc0f02d1440d22934403b8d944218747b9289 (diff) | |
download | gitea-0ae1ed749dd6581379b7ccf483d66051869b52d7.tar.gz gitea-0ae1ed749dd6581379b7ccf483d66051869b52d7.zip |
Remove all package data after tests (#22984)
Fixes #21020
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/db/context.go')
-rw-r--r-- | models/db/context.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/models/db/context.go b/models/db/context.go index 4b3f7f0ee7..670f6272aa 100644 --- a/models/db/context.go +++ b/models/db/context.go @@ -209,7 +209,7 @@ func DecrByIDs(ctx context.Context, ids []int64, decrCol string, bean interface{ return err } -// DeleteBeans deletes all given beans, beans should contain delete conditions. +// DeleteBeans deletes all given beans, beans must contain delete conditions. func DeleteBeans(ctx context.Context, beans ...interface{}) (err error) { e := GetEngine(ctx) for i := range beans { @@ -220,6 +220,17 @@ func DeleteBeans(ctx context.Context, beans ...interface{}) (err error) { return nil } +// TruncateBeans deletes all given beans, beans may contain delete conditions. +func TruncateBeans(ctx context.Context, beans ...interface{}) (err error) { + e := GetEngine(ctx) + for i := range beans { + if _, err = e.Truncate(beans[i]); err != nil { + return err + } + } + return nil +} + // CountByBean counts the number of database records according non-empty fields of the bean as conditions. func CountByBean(ctx context.Context, bean interface{}) (int64, error) { return GetEngine(ctx).Count(bean) |