]> source.dussan.org Git - gitea.git/commitdiff
Fix problem when database ID is not incremented as expected (#17229)
authorfinga <finga@users.noreply.github.com>
Wed, 6 Oct 2021 20:36:24 +0000 (22:36 +0200)
committerGitHub <noreply@github.com>
Wed, 6 Oct 2021 20:36:24 +0000 (15:36 -0500)
Although #17124 fixed the same issue for the feed, some other parts
with the same issue were found.

Co-authored-by: finga <finga@onders.org>
models/admin.go
models/issue.go
models/token.go

index 27a2032e2cf179318bcba1ca5002799d6806dec3..a003aff7e62072daa344b25c776531629a244dd8 100644 (file)
@@ -107,7 +107,7 @@ func Notices(page, pageSize int) ([]*Notice, error) {
        notices := make([]*Notice, 0, pageSize)
        return notices, db.GetEngine(db.DefaultContext).
                Limit(pageSize, (page-1)*pageSize).
-               Desc("id").
+               Desc("created_unix").
                Find(&notices)
 }
 
index 9b02a839006cd8a728fde1d399bd967cd717d603..b62394919ce9a26e420baa5a952b70d151aa0b61 100644 (file)
@@ -843,7 +843,7 @@ func (issue *Issue) GetLastEventLabel() string {
 func (issue *Issue) GetLastComment() (*Comment, error) {
        var c Comment
        exist, err := db.GetEngine(db.DefaultContext).Where("type = ?", CommentTypeComment).
-               And("issue_id = ?", issue.ID).Desc("id").Get(&c)
+               And("issue_id = ?", issue.ID).Desc("created_unix").Get(&c)
        if err != nil {
                return nil, err
        }
index 3cffdd9ba276600413e5f2647ab8cd69c209e126..b3712fce5e5ccd1c5e5070a2d3728e3a0db68150 100644 (file)
@@ -161,7 +161,7 @@ func ListAccessTokens(opts ListAccessTokensOptions) ([]*AccessToken, error) {
                sess = sess.Where("name=?", opts.Name)
        }
 
-       sess = sess.Desc("id")
+       sess = sess.Desc("created_unix")
 
        if opts.Page != 0 {
                sess = db.SetSessionPagination(sess, &opts)