aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfinga <finga@users.noreply.github.com>2021-10-06 22:36:24 +0200
committerGitHub <noreply@github.com>2021-10-06 15:36:24 -0500
commit67bc04fe21e279805f2f4163791e28272e8133b1 (patch)
treea0c4df1fcae930db0cb57f73dda05b4e30d54df3
parent21a784e94a87ebcf9d95860f0e583b0a9bc629c2 (diff)
downloadgitea-67bc04fe21e279805f2f4163791e28272e8133b1.tar.gz
gitea-67bc04fe21e279805f2f4163791e28272e8133b1.zip
Fix problem when database ID is not incremented as expected (#17229)
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>
-rw-r--r--models/admin.go2
-rw-r--r--models/issue.go2
-rw-r--r--models/token.go2
3 files changed, 3 insertions, 3 deletions
diff --git a/models/admin.go b/models/admin.go
index 27a2032e2c..a003aff7e6 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -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)
}
diff --git a/models/issue.go b/models/issue.go
index 9b02a83900..b62394919c 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -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
}
diff --git a/models/token.go b/models/token.go
index 3cffdd9ba2..b3712fce5e 100644
--- a/models/token.go
+++ b/models/token.go
@@ -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)