@@ -478,7 +478,7 @@ func storeOrUpdateSysPlatform(tx *gorm.DB, system *models.SystemPlatform, colsTo
478478 }
479479
480480 // return system_platform record after update
481- tx = tx .Clauses (clause.Returning {
481+ txi : = tx .Clauses (clause.Returning {
482482 Columns : []clause.Column {
483483 {Name : "id" }, {Name : "inventory_id" }, {Name : "rh_account_id" },
484484 {Name : "unchanged_since" },
@@ -487,7 +487,7 @@ func storeOrUpdateSysPlatform(tx *gorm.DB, system *models.SystemPlatform, colsTo
487487
488488 if system .ID != 0 {
489489 // update system
490- err := tx .Select (colsToUpdate ).Updates (system ).Error
490+ err := txi .Select (colsToUpdate ).Updates (system ).Error
491491 return base .WrapFatalDBError (err , "unable to update system_platform" )
492492 }
493493 inventoryRecord := models.SystemInventory {
@@ -513,7 +513,7 @@ func storeOrUpdateSysPlatform(tx *gorm.DB, system *models.SystemPlatform, colsTo
513513 inventoryColsToUpdate := slices .DeleteFunc (colsToUpdate , func (col string ) bool {
514514 return col == "template_id"
515515 })
516- err := database .OnConflictUpdateMulti (tx , []string {"rh_account_id" , "inventory_id" }, inventoryColsToUpdate ... ).
516+ err := database .OnConflictUpdateMulti (txi , []string {"rh_account_id" , "inventory_id" }, inventoryColsToUpdate ... ).
517517 Save (& inventoryRecord ).Error
518518 if err != nil {
519519 return base .WrapFatalDBError (err , "unable to insert to system_inventory" )
@@ -534,9 +534,9 @@ func storeOrUpdateSysPlatform(tx *gorm.DB, system *models.SystemPlatform, colsTo
534534 LastEvaluation : system .LastEvaluation ,
535535 TemplateID : system .TemplateID ,
536536 }
537- tx = tx .Clauses (clause.Returning {Columns : []clause.Column {{Name : "last_evaluation" }}})
538- err = database .OnConflictUpdateMulti (tx , []string {"rh_account_id" , "system_id" }, patchColsToUpdate ... ).
539- Save ( patchRecord ).Error
537+ txp : = tx .Clauses (clause.Returning {Columns : []clause.Column {{Name : "last_evaluation" }}})
538+ err = database .OnConflictUpdateMulti (txp , []string {"rh_account_id" , "system_id" }, patchColsToUpdate ... ).
539+ Create ( & patchRecord ).Error
540540 system .LastEvaluation = patchRecord .LastEvaluation
541541 return base .WrapFatalDBError (err , "unable to insert to system_platform" )
542542}
0 commit comments