Apply coredata rules: idempotent deletes and constraint checks
Delete methods no longer check RowsAffected — deletes are idempotent. PgError handlers now check both error code and constraint name to avoid misattributing violations. Also migrated remaining errors.As patterns to errors.AsType. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -367,7 +367,7 @@ INSERT INTO iam_oauth2_consents (
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" {
|
||||
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok && pgErr.Code == "23505" && pgErr.ConstraintName == "iam_oauth2_consents_pkey" {
|
||||
return ErrResourceAlreadyExists
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user