Failed Transaction Does Not Throw Error #218

Closed
opened 2025-07-01 11:11:49 +00:00 by Quaternions · 0 comments
Owner

The IfStatusThenUpdate function does not throw an error when the transaction fails due to no records found:

func (env *Mapfixes) IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.MapfixStatus, values datastore.OptionalMap) error {
if err := env.db.Model(&model.Mapfix{}).Where("id = ?", id).Where("status_id IN ?", statuses).Updates(values.Map()).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return datastore.ErrNotExist
}
return err
}
return nil
}

The code here appears to check if the transaction has zero rows affected, but there does not seem to be any error thrown...

The IfStatusThenUpdate function does not throw an error when the transaction fails due to no records found: https://git.itzana.me/StrafesNET/maps-service/src/commit/0f0ab4d3e0d09fdc67686a4ffc624e726ca3ab78/pkg/datastore/gormstore/mapfixes.go#L57-L66 The code here appears to check if the transaction has zero rows affected, but there does not seem to be any error thrown...
Quaternions added the backend label 2025-07-01 11:12:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: StrafesNET/maps-service#218