Skip to content

Commit fd98244

Browse files
authored
🐛 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 <[email protected]>
1 parent c914669 commit fd98244

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

importer/manager.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,22 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) {
166166
}
167167

168168
// Assign Business Service
169-
businessService := &model.BusinessService{}
169+
businessService := model.BusinessService{}
170170
businessServices := []model.BusinessService{}
171171
m.DB.Find(&businessServices)
172172
normBusinessServiceName := normalizedName(imp.BusinessService)
173173
// Find existing BusinessService
174174
for _, bs := range businessServices {
175175
if normalizedName(bs.Name) == normBusinessServiceName {
176-
businessService = &bs
176+
businessService = bs
177177
}
178178
}
179179
// If not found business service in database and import specifies some non-empty business service, proceeed with create it
180180
if businessService.ID == 0 && normBusinessServiceName != "" {
181181
if imp.ImportSummary.CreateEntities {
182182
// Create a new BusinessService if not existed
183183
businessService.Name = imp.BusinessService
184-
result := m.DB.Create(businessService)
184+
result := m.DB.Create(&businessService)
185185
if result.Error != nil {
186186
imp.ErrorMessage = fmt.Sprintf("BusinessService '%s' cannot be created.", imp.BusinessService)
187187
return
@@ -193,7 +193,7 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) {
193193
}
194194
// Assign business service to the application if was specified
195195
if businessService.ID != 0 {
196-
app.BusinessService = businessService
196+
app.BusinessService = &businessService
197197
}
198198

199199
// Process import Tags & TagCategories

0 commit comments

Comments
 (0)