Skip to content

Commit

Permalink
Don't join repository when loading action table data (go-gitea#32127)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Sep 26, 2024
1 parent 634454c commit 75d156a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions models/activities/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
return nil, 0, err
}

sess := db.GetEngine(ctx).Where(cond).
Select("`action`.*"). // this line will avoid select other joined table's columns
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
sess := db.GetEngine(ctx).Where(cond)

opts.SetDefaultValues()
sess = db.SetSessionPagination(sess, &opts)
Expand Down
6 changes: 4 additions & 2 deletions models/activities/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ func TestNotifyWatchers(t *testing.T) {
}

func TestGetFeedsCorrupted(t *testing.T) {
// Now we will not check for corrupted data in the feeds
// users should run doctor to fix their data
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{
Expand All @@ -239,8 +241,8 @@ func TestGetFeedsCorrupted(t *testing.T) {
IncludePrivate: true,
})
assert.NoError(t, err)
assert.Len(t, actions, 0)
assert.Equal(t, int64(0), count)
assert.Len(t, actions, 1)
assert.Equal(t, int64(1), count)
}

func TestConsistencyUpdateAction(t *testing.T) {
Expand Down

0 comments on commit 75d156a

Please sign in to comment.