Skip to content

Commit 35b2e84

Browse files
committed
Fix check for rows affected
1 parent 17cb069 commit 35b2e84

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

api/pkg/repositories/gorm_billing_usage_repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (repository *gormBillingUsageRepository) RegisterSentMessage(ctx context.Co
4747
Where("user_id = ?", userID).
4848
UpdateColumn("sent_messages", gorm.Expr("sent_messages + ?", 1))
4949

50-
if result.RowsAffected == 0 {
50+
if result.Error == nil && result.RowsAffected == 0 {
5151
return tx.Create(repository.createBillingUsage(userID, 1, 0)).Error
5252
}
5353
return result.Error
@@ -68,7 +68,7 @@ func (repository *gormBillingUsageRepository) RegisterReceivedMessage(ctx contex
6868
Where("user_id = ?", userID).
6969
UpdateColumn("sent_messages", gorm.Expr("received_messages + ?", 1))
7070

71-
if result.RowsAffected == 0 {
71+
if result.Error == nil && result.RowsAffected == 0 {
7272
return tx.Create(repository.createBillingUsage(userID, 0, 1)).Error
7373
}
7474
return result.Error

0 commit comments

Comments
 (0)