Skip to content

Commit

Permalink
Fix problem when database ID is not incremented as expected (#17229)
Browse files Browse the repository at this point in the history
Although #17124 fixed the same issue for the feed, some other parts
with the same issue were found.

Co-authored-by: finga <[email protected]>
  • Loading branch information
finga and finga authored Oct 6, 2021
1 parent 21a784e commit 67bc04f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion models/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion models/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 67bc04f

Please sign in to comment.