ssosettings: Don't update primary key in sso_setting table. (#102878)
Don't update primary key in sso_setting table.
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
idColumn = "id"
|
||||
isDeletedColumn = "is_deleted"
|
||||
updatedColumn = "updated"
|
||||
)
|
||||
@@ -143,7 +144,10 @@ func (s *SSOSettingsStore) Delete(ctx context.Context, provider string) error {
|
||||
existing.Updated = time.Now().UTC()
|
||||
existing.IsDeleted = true
|
||||
|
||||
_, err = sess.ID(existing.ID).MustCols(updatedColumn, isDeletedColumn).Update(existing)
|
||||
// We must explicitly omit ID column from updates, because some databases (e.g. Spanner) don't allow updating
|
||||
// primary key. Xorm ignores autoincrement columns during updates, but since ID column here is a string,
|
||||
// it's not ignored by default.
|
||||
_, err = sess.ID(existing.ID).Omit(idColumn).MustCols(updatedColumn, isDeletedColumn).Update(existing)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user