Stable sort order for DB lists (#1702)

This commit is contained in:
qwerty287 2023-04-11 09:33:27 +02:00 committed by GitHub
parent c40a6d884f
commit a06d3e1a61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -28,7 +28,7 @@ func (s storage) RegistryFind(repo *model.Repo, addr string) (*model.Registry, e
func (s storage) RegistryList(repo *model.Repo) ([]*model.Registry, error) {
regs := make([]*model.Registry, 0, perPage)
return regs, s.engine.Where("registry_repo_id = ?", repo.ID).Find(&regs)
return regs, s.engine.OrderBy("registry_id").Where("registry_repo_id = ?", repo.ID).Find(&regs)
}
func (s storage) RegistryCreate(registry *model.Registry) error {

View file

@ -71,7 +71,7 @@ func (s storage) OrgSecretFind(owner, name string) (*model.Secret, error) {
func (s storage) OrgSecretList(owner string) ([]*model.Secret, error) {
secrets := make([]*model.Secret, 0, perPage)
return secrets, s.engine.Where("secret_owner = ?", owner).Find(&secrets)
return secrets, s.engine.Where("secret_owner = ?", owner).OrderBy(orderSecretsBy).Find(&secrets)
}
func (s storage) GlobalSecretFind(name string) (*model.Secret, error) {

View file

@ -30,7 +30,7 @@ func (s storage) GetUserLogin(login string) (*model.User, error) {
func (s storage) GetUserList() ([]*model.User, error) {
users := make([]*model.User, 0, 10)
return users, s.engine.Find(&users)
return users, s.engine.OrderBy("user_id").Find(&users)
}
func (s storage) GetUserCount() (int64, error) {