2 files changed,
4 insertions(+),
7 deletions(-)
Author:
Smirnov Oleksandr
ss2316544@gmail.com
Committed by:
GitHub
noreply@github.com
Committed at:
2025-06-25 14:01:47 +0300
Parent:
babda7d
M
internal/store/psqlutil/psqlutil.go
··· 31 31 } 32 32 33 33 // IsDuplicateErr function that checks if the error is a duplicate key violation. 34 -func IsDuplicateErr(err error, constraintName ...string) bool { 34 +func IsDuplicateErr(err error, constraintName string) bool { 35 35 var pgErr *pgconn.PgError 36 36 if errors.As(err, &pgErr) { 37 - if len(constraintName) == 0 || len(constraintName) == 1 { 38 - return pgErr.Code == "23505" && // unique_violation 39 - pgErr.ConstraintName == constraintName[0] 40 - } 41 - return pgErr.Code == "23505" // unique_violation 37 + return pgErr.Code == "23505" && // unique_violation 38 + pgErr.ConstraintName == constraintName 42 39 } 43 40 return false 44 41 }