Skip to content

Commit 1eae2aa

Browse files
authored
Fix issue not showing on default board and add test (#27720)
See #27718 (comment) . Add a test to ensure its behavior. Why this test uses `ProjectBoardID=0`? Because in `SearchOptions`, `ProjectBoardID=0` means what it is. But in `IssueOptions`, `ProjectBoardID=0` means there is no condition, and `ProjectBoardID=db.NoConditionID` means the board ID = 0. It's really confusing. Probably it's better to separate the db search engine and the other issue search code. It's really two different systems. As far as I can see, `IssueOptions` is not necessary for most of the code, which has very simple issue search conditions.
1 parent 31f8880 commit 1eae2aa

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

models/issues/issue_search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func applyProjectBoardCondition(sess *xorm.Session, opts *IssuesOptions) *xorm.S
186186
if opts.ProjectBoardID > 0 {
187187
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": opts.ProjectBoardID}))
188188
} else if opts.ProjectBoardID == db.NoConditionID {
189-
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Neq{"project_board_id": 0}))
189+
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": 0}))
190190
}
191191
return sess
192192
}

modules/indexer/issues/indexer_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ func searchIssueInProject(t *testing.T) {
382382
},
383383
[]int64{1},
384384
},
385+
{
386+
SearchOptions{
387+
ProjectBoardID: int64Pointer(0), // issue with in default board
388+
},
389+
[]int64{2},
390+
},
385391
}
386392
for _, test := range tests {
387393
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts)

0 commit comments

Comments
 (0)