We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51cd386 commit a73cc5dCopy full SHA for a73cc5d
internal/sms-gateway/modules/messages/repository.go
@@ -136,7 +136,7 @@ func (r *Repository) Insert(message *Message) error {
136
return nil
137
}
138
139
- if errors.Is(err, gorm.ErrDuplicatedKey) || mysql.IsPrimaryKeyViolation(err) {
+ if errors.Is(err, gorm.ErrDuplicatedKey) || mysql.IsDuplicateKeyViolation(err) {
140
return ErrMessageAlreadyExists
141
142
pkg/mysql/errors.go
@@ -6,7 +6,7 @@ import (
6
"github.com/go-sql-driver/mysql"
7
)
8
9
-func IsPrimaryKeyViolation(err error) bool {
+func IsDuplicateKeyViolation(err error) bool {
10
var me *mysql.MySQLError
11
if errors.As(err, &me) {
12
return me.Number == 1062
0 commit comments