From d44de7f20a1e9f1f49c1e7e37d58da6fe1dee593 Mon Sep 17 00:00:00 2001 From: Yuri Tseretyan Date: Fri, 6 Jan 2023 21:23:46 -0500 Subject: [PATCH] Annotations: AddMany to not open session if nothing to save (#61117) --- pkg/services/annotations/annotationsimpl/xorm_store.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/services/annotations/annotationsimpl/xorm_store.go b/pkg/services/annotations/annotationsimpl/xorm_store.go index 21f1aeec6cd..33f75061479 100644 --- a/pkg/services/annotations/annotationsimpl/xorm_store.go +++ b/pkg/services/annotations/annotationsimpl/xorm_store.go @@ -77,7 +77,9 @@ func (r *xormRepositoryImpl) Add(ctx context.Context, item *annotations.Item) er func (r *xormRepositoryImpl) AddMany(ctx context.Context, items []annotations.Item) error { hasTags := make([]annotations.Item, 0) hasNoTags := make([]annotations.Item, 0) - + if len(items) == 0 { + return nil + } for i := range items { // The validation logic needs to work in terms of pointers. // So, force everything else to work in terms of pointers too, to avoid any implicit extra copying.