mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-26 01:40:36 +00:00
Fix bug because of duplicated join (#14454)
* Fix bug because of duplicated join * Move join into setupsession * Fix bug * Fix bug Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
a598877fdf
commit
d3aa4971c7
1 changed files with 7 additions and 2 deletions
|
@ -1210,7 +1210,7 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.IsArchived != util.OptionalBoolNone {
|
if opts.IsArchived != util.OptionalBoolNone {
|
||||||
sess.Join("INNER", "repository", "issue.repo_id = repository.id").And(builder.Eq{"repository.is_archived": opts.IsArchived.IsTrue()})
|
sess.And(builder.Eq{"repository.is_archived": opts.IsArchived.IsTrue()})
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.LabelIDs != nil {
|
if opts.LabelIDs != nil {
|
||||||
|
@ -1266,6 +1266,8 @@ func CountIssuesByRepo(opts *IssuesOptions) (map[int64]int64, error) {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
|
||||||
|
sess.Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
|
||||||
|
|
||||||
opts.setupSession(sess)
|
opts.setupSession(sess)
|
||||||
|
|
||||||
countsSlice := make([]*struct {
|
countsSlice := make([]*struct {
|
||||||
|
@ -1292,11 +1294,12 @@ func GetRepoIDsForIssuesOptions(opts *IssuesOptions, user *User) ([]int64, error
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
|
||||||
|
sess.Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
|
||||||
|
|
||||||
opts.setupSession(sess)
|
opts.setupSession(sess)
|
||||||
|
|
||||||
accessCond := accessibleRepositoryCondition(user)
|
accessCond := accessibleRepositoryCondition(user)
|
||||||
if err := sess.Where(accessCond).
|
if err := sess.Where(accessCond).
|
||||||
Join("INNER", "repository", "`issue`.repo_id = `repository`.id").
|
|
||||||
Distinct("issue.repo_id").
|
Distinct("issue.repo_id").
|
||||||
Table("issue").
|
Table("issue").
|
||||||
Find(&repoIDs); err != nil {
|
Find(&repoIDs); err != nil {
|
||||||
|
@ -1311,6 +1314,7 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
defer sess.Close()
|
defer sess.Close()
|
||||||
|
|
||||||
|
sess.Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
|
||||||
opts.setupSession(sess)
|
opts.setupSession(sess)
|
||||||
sortIssuesSession(sess, opts.SortType, opts.PriorityRepoID)
|
sortIssuesSession(sess, opts.SortType, opts.PriorityRepoID)
|
||||||
|
|
||||||
|
@ -1338,6 +1342,7 @@ func CountIssues(opts *IssuesOptions) (int64, error) {
|
||||||
}, 0, 1)
|
}, 0, 1)
|
||||||
|
|
||||||
sess.Select("COUNT(issue.id) AS count").Table("issue")
|
sess.Select("COUNT(issue.id) AS count").Table("issue")
|
||||||
|
sess.Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
|
||||||
opts.setupSession(sess)
|
opts.setupSession(sess)
|
||||||
if err := sess.Find(&countsSlice); err != nil {
|
if err := sess.Find(&countsSlice); err != nil {
|
||||||
return 0, fmt.Errorf("Find: %v", err)
|
return 0, fmt.Errorf("Find: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue