Channel Store: No SELECT * (#32167)
* Replace SELECT * with explicit column lists in channel store Migrates channel_store.go away from SELECT * patterns to explicit column lists for better performance, maintainability, and schema safety. - Replace GetPinnedPosts raw SQL with query builder using postSliceColumns() - Replace "cc.*" in group channel search with channelSliceColumns() - Replace GetChannelsBatchForIndexing raw SQL with query builder - Replace channel member and team queries with respective column helpers - Use SelectBuilder helper instead of manual ToSql() calls 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Replace SELECT * with COUNT(*) in user_test.go Replaces unnecessary SELECT * queries with SELECT COUNT(*) in TestPermanentDeleteUser bot count verification. Only needs to check the count of bots, not retrieve full bot records. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fb9b05b764
Коммит
ebe03c1d45
@@ -7076,7 +7076,7 @@ func testChannelStoreSearchGroupChannels(t *testing.T, rctx request.CTX, ss stor
|
||||
require.NoError(t, nErr)
|
||||
|
||||
for _, userID := range userIds {
|
||||
_, err := ss.Channel().SaveMember(rctx, &model.ChannelMember{
|
||||
_, err = ss.Channel().SaveMember(rctx, &model.ChannelMember{
|
||||
ChannelId: gc2.Id,
|
||||
UserId: userID,
|
||||
NotifyProps: model.GetDefaultChannelNotifyProps(),
|
||||
@@ -7092,6 +7092,20 @@ func testChannelStoreSearchGroupChannels(t *testing.T, rctx request.CTX, ss stor
|
||||
_, nErr = ss.Channel().Save(rctx, &gc3, -1)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
// Make gc3 policy enforced
|
||||
_, err = ss.AccessControlPolicy().Save(rctx, &model.AccessControlPolicy{
|
||||
ID: gc3.Id,
|
||||
Version: model.AccessControlPolicyVersionV0_1,
|
||||
Type: model.AccessControlPolicyTypeChannel,
|
||||
Rules: []model.AccessControlPolicyRule{
|
||||
{
|
||||
Actions: []string{},
|
||||
Expression: "",
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, userID := range userIds {
|
||||
_, err := ss.Channel().SaveMember(rctx, &model.ChannelMember{
|
||||
ChannelId: gc3.Id,
|
||||
@@ -7108,6 +7122,16 @@ func testChannelStoreSearchGroupChannels(t *testing.T, rctx request.CTX, ss stor
|
||||
}
|
||||
}()
|
||||
|
||||
// assertChannelListPopulated verifies that the channel objects in the given channel list
|
||||
// are fully populated.
|
||||
assertChannelListPopulated := func(t *testing.T, channelList model.ChannelList) {
|
||||
for _, actualChannel := range channelList {
|
||||
expectedChannel, err := ss.Channel().Get(actualChannel.Id, false)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedChannel, actualChannel, "channel %q in channel list missing metadata", actualChannel.Id)
|
||||
}
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
Name string
|
||||
UserID string
|
||||
@@ -7169,6 +7193,7 @@ func testChannelStoreSearchGroupChannels(t *testing.T, rctx request.CTX, ss stor
|
||||
}
|
||||
|
||||
require.ElementsMatch(t, tc.ExpectedResult, resultIds)
|
||||
assertChannelListPopulated(t, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user