From 4e85b28c2cc33cb8edf32e1979ccdedd4061947c 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 540214e2c..2969c985e 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -166,14 +166,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 @@ -181,7 +181,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 @@ -193,7 +193,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