From 55e98f5f366fd26fb7fe9bc5c1fe1904a2e01887 Mon Sep 17 00:00:00 2001 From: Marek Aufart Date: Mon, 25 Nov 2024 16:38:35 +0100 Subject: [PATCH] :bug: Fix BusinessService CSV import (#766) CSV importer code used to set the last existing BussinessService to an Application, updating businessService variable from Ref to Value to keep the found BusinessService until it is saved in Application. Fixes: https://issues.redhat.com/browse/MTA-4257 Signed-off-by: Marek Aufart Signed-off-by: Cherry Picker --- importer/manager.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/importer/manager.go b/importer/manager.go index b11f45e4b..275db132b 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -168,14 +168,14 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) { } // Assign Business Service - businessService := &model.BusinessService{} + businessService := model.BusinessService{} businessServices := []model.BusinessService{} m.DB.Find(&businessServices) normBusinessServiceName := normalizedName(imp.BusinessService) // Find existing BusinessService for _, bs := range businessServices { if normalizedName(bs.Name) == normBusinessServiceName { - businessService = &bs + businessService = bs } } // If not found business service in database and import specifies some non-empty business service, proceeed with create it @@ -183,7 +183,7 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) { if imp.ImportSummary.CreateEntities { // Create a new BusinessService if not existed businessService.Name = imp.BusinessService - result := m.DB.Create(businessService) + result := m.DB.Create(&businessService) if result.Error != nil { imp.ErrorMessage = fmt.Sprintf("BusinessService '%s' cannot be created.", imp.BusinessService) return @@ -195,7 +195,7 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) { } // Assign business service to the application if was specified if businessService.ID != 0 { - app.BusinessService = businessService + app.BusinessService = &businessService } // Process import Tags & TagCategories