Skip to content

Commit e49a3e5

Browse files
authored
fix: ensure identities are returned in a consistent order across DB engines (#2465)
Returns identities in a consistent order to work across DB engines. Previously, we were relying on Postgres' implicit ordering which is considered an implementation detail and does not carry across to Oriole DB (https://github.com/supabase/auth/actions/runs/24069608972/job/70203207256?pr=2464). Although we don't have an index on created_at, this should be fine since a user is unlikely to have many indexes and `FindProvidersByUser` filters by the user_id first. Related: #2464
1 parent 983ade6 commit e49a3e5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

internal/models/identity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func FindProvidersByUser(tx *storage.Connection, user *User) ([]string, error) {
103103
identities := []Identity{}
104104
providerExists := map[string]bool{}
105105
providers := make([]string, 0)
106-
if err := tx.Q().Select("provider").Where("user_id = ?", user.ID).All(&identities); err != nil {
106+
if err := tx.Q().Select("provider").Where("user_id = ?", user.ID).Order("created_at asc").All(&identities); err != nil {
107107
if errors.Cause(err) == sql.ErrNoRows {
108108
return providers, nil
109109
}

0 commit comments

Comments
 (0)