Skip to content

Commit 4aa4660

Browse files
committed
RHINENG-22011: update getSubscribedSystem to use First instead of Find in sql
1 parent 3df0224 commit 4aa4660

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

manager/controllers/template_subscribed_systems_update.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ func getSubscribedSystem(c *gin.Context, tx *gorm.DB) (int, string, error) {
7373
Table("inventory.hosts ih").
7474
Joins("JOIN rh_account acc on ih.org_id = acc.org_id").
7575
Where("ih.system_profile->>'owner_id' = ? AND acc.id = ?", systemCn, account).
76-
// use Find() not First() otherwise it returns error "no rows found" if uuid is not present
77-
Find(&inventoryID).Error
78-
if err != nil {
76+
Limit(1).Find(&inventoryID).Error
77+
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
7978
utils.LogAndRespError(c, err, "database error")
8079
return 0, "", err
8180
}

0 commit comments

Comments
 (0)