Skip to content

Commit

Permalink
feat: index hint for CRDB when deleting identity credentials (#4276)
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr authored Jan 27, 2025
1 parent c9fe7d6 commit c703a33
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions persistence/sql/identity/persister_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,11 +1085,13 @@ func (p *IdentityPersister) UpdateIdentity(ctx context.Context, i *identity.Iden
return err
}

// #nosec G201 -- TableName is static
tableName := "identity_credentials"
if tx.Dialect.Name() == "cockroach" {
tableName += "@identity_credentials_identity_id_idx"
}
if err := tx.RawQuery(
fmt.Sprintf(
`DELETE FROM %s WHERE identity_id = ? AND nid = ?`,
new(identity.Credentials).TableName(ctx)),
// #nosec G201 -- TableName is static
fmt.Sprintf(`DELETE FROM %s WHERE identity_id = ? AND nid = ?`, tableName),
i.ID, p.NetworkID(ctx)).Exec(); err != nil {
return sqlcon.HandleError(err)
}
Expand Down

0 comments on commit c703a33

Please sign in to comment.