Этот коммит содержится в:
Ben Schumacher
2023-10-11 10:13:36 +02:00
коммит произвёл GitHub
родитель 176370e175
Коммит 0d5a8b8841
189 изменённых файлов: 1 добавлений и 361 удалений

Просмотреть файл

@@ -683,7 +683,6 @@ func (s SqlChannelStore) SaveDirectChannel(directChannel *model.Channel, member1
}
return newChannel, nil
}
func (s SqlChannelStore) saveChannelT(transaction *sqlxTxWrapper, channel *model.Channel, maxChannelsPerTeam int64) (*model.Channel, error) {
@@ -2971,7 +2970,6 @@ func (s SqlChannelStore) GetForPost(postId string) (*model.Channel, error) {
Channels.Id = Posts.ChannelId
AND Posts.Id = ?`, postId); err != nil {
return nil, errors.Wrapf(err, "failed to get Channel with postId=%s", postId)
}
return &channel, nil
}
@@ -3526,7 +3524,6 @@ func (s SqlChannelStore) channelSearchQuery(opts *store.ChannelSearchOpts) sq.Se
query = query.
LeftJoin("RetentionPoliciesChannels ON c.Id = RetentionPoliciesChannels.ChannelId").
Where("RetentionPoliciesChannels.ChannelId IS NULL")
} else {
query = query.Where(sq.Expr(`c.Id NOT IN (SELECT ChannelId FROM RetentionPoliciesChannels)`))
}
@@ -3770,7 +3767,6 @@ func (s SqlChannelStore) buildFulltextClauseX(term string, searchColumns ...stri
expr := fmt.Sprintf("((to_tsvector('%[1]s', %[2]s)) @@ to_tsquery('%[1]s', ?))", s.pgDefaultTextSearchConfig, strings.Join(searchColumns, " || ' ' || "))
return sq.Expr(expr, fulltextTerm)
}
splitTerm := strings.Fields(fulltextTerm)
@@ -3846,7 +3842,6 @@ func (s SqlChannelStore) searchGroupChannelsQuery(userId, term string, isPostgre
return s.getQueryBuilder().Select("*").
From("Channels").
Where(sq.Expr("Id IN (?)", subq))
}
baseLikeTerm = "GROUP_CONCAT(u.Username SEPARATOR ', ') LIKE ?"
@@ -4067,7 +4062,6 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
WHERE ChannelId=:ChannelId AND UserId=:UserId`, &member); err != nil {
return nil, errors.Wrap(err, "failed to update ChannelMember")
}
}
if err := transaction.Commit(); err != nil {

Просмотреть файл

@@ -421,7 +421,6 @@ func TestCheckChannelsCommandWebhooksIntegrity(t *testing.T) {
require.NoError(t, result.Err)
data := result.Data.(model.RelationalIntegrityCheckData)
require.Empty(t, data.Records)
})
t.Run("should generate a report with one record", func(t *testing.T) {
channelId := model.NewId()

Просмотреть файл

@@ -53,7 +53,6 @@ func (ls SqlLicenseStore) Save(license *model.LicenseRecord) error {
}
return nil
}
// Get obtains the license with the provided id parameter from the database.

Просмотреть файл

@@ -637,7 +637,6 @@ func (s *SqlPostStore) getPostWithCollapsedThreads(id, userID string, opts model
sq.Lt{"Posts.Id": opts.FromPost},
},
})
} else {
query = query.Where(direction)
}
@@ -759,7 +758,6 @@ func (s *SqlPostStore) Get(ctx context.Context, id string, opts model.GetPostsOp
sq.Lt{"p.Id": opts.FromPost},
},
})
} else {
query = query.Where(direction)
}
@@ -2220,7 +2218,6 @@ func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.A
// TODO: convert to squirrel HW
func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCountsOptions) (model.AnalyticsRows, error) {
var args []any
query :=
`SELECT

Просмотреть файл

@@ -172,7 +172,6 @@ func (s SqlPreferenceStore) GetCategory(userId string, category string) (model.P
return nil, errors.Wrapf(err, "failed to find Preference with userId=%s, category=%s", userId, category)
}
return preferences, nil
}
func (s SqlPreferenceStore) GetAll(userId string) (model.Preferences, error) {
@@ -205,7 +204,6 @@ func (s SqlPreferenceStore) PermanentDeleteByUser(userId string) error {
}
func (s SqlPreferenceStore) Delete(userId, category, name string) error {
sql, args, err := s.getQueryBuilder().
Delete("Preferences").
Where(sq.Eq{"UserId": userId}).
@@ -224,7 +222,6 @@ func (s SqlPreferenceStore) Delete(userId, category, name string) error {
}
func (s SqlPreferenceStore) DeleteCategory(userId string, category string) error {
sql, args, err := s.getQueryBuilder().
Delete("Preferences").
Where(sq.Eq{"UserId": userId}).

Просмотреть файл

@@ -440,7 +440,6 @@ func (ss *SqlStore) GetDbVersion(numerical bool) (string, error) {
}
return version, nil
}
func (ss *SqlStore) GetMasterX() *sqlxDBWrapper {
@@ -654,7 +653,6 @@ func (ss *SqlStore) DoesTableExist(tableName string) bool {
}
return count > 0
} else if ss.DriverName() == model.DatabaseDriverMysql {
var count int64
err := ss.GetMasterX().Get(&count,
@@ -674,7 +672,6 @@ func (ss *SqlStore) DoesTableExist(tableName string) bool {
}
return count > 0
} else {
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
@@ -703,7 +700,6 @@ func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
}
return count > 0
} else if ss.DriverName() == model.DatabaseDriverMysql {
var count int64
err := ss.GetMasterX().Get(&count,
@@ -724,7 +720,6 @@ func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
}
return count > 0
} else {
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
@@ -748,7 +743,6 @@ func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
}
return count > 0
} else if ss.DriverName() == model.DatabaseDriverMysql {
var count int64
err := ss.GetMasterX().Get(&count, `
@@ -766,7 +760,6 @@ func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
}
return count > 0
} else {
mlog.Fatal("Failed to check if column exists because of missing driver")
return false
@@ -774,7 +767,6 @@ func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
}
func (ss *SqlStore) CreateColumnIfNotExists(tableName string, columnName string, mySqlColType string, postgresColType string, defaultValue string) bool {
if ss.DoesColumnExist(tableName, columnName) {
return false
}
@@ -786,7 +778,6 @@ func (ss *SqlStore) CreateColumnIfNotExists(tableName string, columnName string,
}
return true
} else if ss.DriverName() == model.DatabaseDriverMysql {
_, err := ss.GetMasterX().ExecNoTimeout("ALTER TABLE " + tableName + " ADD " + columnName + " " + mySqlColType + " DEFAULT '" + defaultValue + "'")
if err != nil {
@@ -794,7 +785,6 @@ func (ss *SqlStore) CreateColumnIfNotExists(tableName string, columnName string,
}
return true
} else {
mlog.Fatal("Failed to create column because of missing driver")
return false
@@ -1106,7 +1096,6 @@ func (ss *SqlStore) DropAllTables() {
for _, t := range tables {
if t != "db_migrations" {
ss.masterX.Exec(`TRUNCATE TABLE ` + t)
}
}
}

Просмотреть файл

@@ -310,7 +310,6 @@ func TestGetReplica(t *testing.T) {
for replica := range replicas {
assert.NotSame(t, store.GetMasterX(), replica)
}
} else if assert.Len(t, replicas, 1) {
// Otherwise ensure the replicas contains only the master.
for replica := range replicas {
@@ -382,7 +381,6 @@ func TestGetReplica(t *testing.T) {
for replica := range replicas {
assert.Same(t, store.GetMasterX(), replica)
}
} else if assert.Len(t, replicas, 1) {
// Otherwise ensure the replicas contains only the master.
for replica := range replicas {
@@ -397,7 +395,6 @@ func TestGetReplica(t *testing.T) {
for searchReplica := range searchReplicas {
assert.Same(t, store.GetMasterX(), searchReplica)
}
} else if testCase.DataSourceReplicaNum > 0 {
assert.Equal(t, len(replicas), len(searchReplicas))
for k := range replicas {
@@ -567,7 +564,6 @@ func TestIsBinaryParamEnabled(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, tests[i].expected, ok)
}
}
func TestGetAllConns(t *testing.T) {

Просмотреть файл

@@ -248,7 +248,6 @@ func (s SqlTeamStore) Save(team *model.Team) (*model.Team, error) {
// if the team exists in the database.
// It returns the updated team if the operation is successful.
func (s SqlTeamStore) Update(team *model.Team) (*model.Team, error) {
team.PreUpdate()
if err := team.IsValid(); err != nil {
@@ -259,7 +258,6 @@ func (s SqlTeamStore) Update(team *model.Team) (*model.Team, error) {
err := s.GetMasterX().Get(&oldTeam, `SELECT * FROM Teams WHERE Id=?`, team.Id)
if err != nil {
return nil, errors.Wrapf(err, "failed to get Team with id=%s", team.Id)
}
if oldTeam.Id == "" {
@@ -365,7 +363,6 @@ func (s SqlTeamStore) GetByEmptyInviteID() ([]*model.Team, error) {
// If there is no match in the database, it returns a model.AppError with a
// http.StatusNotFound in the StatusCode field.
func (s SqlTeamStore) GetByName(name string) (*model.Team, error) {
team := model.Team{}
query, args, err := s.teamsQuery.Where(sq.Eq{"Name": name}).ToSql()
if err != nil {
@@ -1337,7 +1334,6 @@ func (s SqlTeamStore) MigrateTeamMembers(fromTeamId string, fromUserId string) (
WHERE TeamId=:TeamId AND UserId=:UserId`, &member); err != nil {
return nil, errors.Wrap(err, "failed to update TeamMember")
}
}
if err := transaction.Commit(); err != nil {
@@ -1369,7 +1365,6 @@ func (s SqlTeamStore) InvalidateAllTeamIdsForUser(userId string) {}
// ClearAllCustomRoleAssignments removes all custom role assignments from TeamMembers.
func (s SqlTeamStore) ClearAllCustomRoleAssignments() (err error) {
builtInRoles := model.MakeDefaultRoles()
lastUserId := strings.Repeat("0", 26)
lastTeamId := strings.Repeat("0", 26)

Просмотреть файл

@@ -587,7 +587,6 @@ func (s *SqlThreadStore) MarkAllAsReadByChannels(userID string, channelIDs []str
var query sq.UpdateBuilder
if s.DriverName() == model.DatabaseDriverPostgres {
query = s.getQueryBuilder().Update("ThreadMemberships").From("Threads")
} else {
query = s.getQueryBuilder().Update("ThreadMemberships", "Threads")
}

Просмотреть файл

@@ -57,11 +57,9 @@ func (s SqlUserAccessTokenStore) Delete(tokenId string) (err error) {
}
return nil
}
func (s SqlUserAccessTokenStore) deleteSessionsAndTokensById(transaction *sqlxTxWrapper, tokenId string) error {
query := ""
if s.DriverName() == model.DatabaseDriverPostgres {
query = "DELETE FROM Sessions s USING UserAccessTokens o WHERE o.Token = s.Token AND o.Id = ?"
@@ -77,7 +75,6 @@ func (s SqlUserAccessTokenStore) deleteSessionsAndTokensById(transaction *sqlxTx
}
func (s SqlUserAccessTokenStore) deleteTokensById(transaction *sqlxTxWrapper, tokenId string) error {
if _, err := transaction.Exec("DELETE FROM UserAccessTokens WHERE Id = ?", tokenId); err != nil {
return errors.Wrapf(err, "failed to delete UserAccessToken id=%s", tokenId)
}

Просмотреть файл

@@ -455,7 +455,6 @@ func (us SqlUserStore) Get(ctx context.Context, id string) (*model.User, error)
return nil, store.NewErrNotFound("User", id)
}
return nil, errors.Wrapf(err, "failed to get User with userId=%s", id)
}
if err = json.Unmarshal(props, &user.Props); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal user props")
@@ -580,7 +579,6 @@ func applyMultiRoleFilters(query sq.SelectBuilder, systemRoles []string, teamRol
sqOr = append(sqOr, sq.Like{"u.Roles": queryRole})
}
}
}
}
@@ -1304,7 +1302,6 @@ func (us SqlUserStore) GetForLogin(loginId string, allowSignInWithUsername, allo
}
return users[0], nil
}
func (us SqlUserStore) VerifyEmail(userId, email string) (string, error) {
@@ -1378,7 +1375,6 @@ func (us SqlUserStore) Count(options model.UserCountOptions) (int64, error) {
}
func (us SqlUserStore) AnalyticsActiveCount(timePeriod int64, options model.UserCountOptions) (int64, error) {
time := model.GetMillis() - timePeriod
query := us.getQueryBuilder().Select("COUNT(*)").From("Status AS s").Where("LastActivityAt > ?", time)

Просмотреть файл

@@ -131,7 +131,6 @@ func (s SqlWebhookStore) GetIncomingListByUser(userId string, offset, limit int)
}
return webhooks, nil
}
func (s SqlWebhookStore) GetIncomingByTeamByUser(teamId string, userId string, offset, limit int) ([]*model.IncomingWebhook, error) {
@@ -198,7 +197,6 @@ func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) (*model.Ou
}
func (s SqlWebhookStore) GetOutgoing(id string) (*model.OutgoingWebhook, error) {
var webhook model.OutgoingWebhook
if err := s.GetReplicaX().Get(&webhook, "SELECT * FROM OutgoingWebhooks WHERE Id = ? AND DeleteAt = 0", id); err != nil {
@@ -240,7 +238,6 @@ func (s SqlWebhookStore) GetOutgoingListByUser(userId string, offset, limit int)
func (s SqlWebhookStore) GetOutgoingList(offset, limit int) ([]*model.OutgoingWebhook, error) {
return s.GetOutgoingListByUser("", offset, limit)
}
func (s SqlWebhookStore) GetOutgoingByChannelByUser(channelId string, userId string, offset, limit int) ([]*model.OutgoingWebhook, error) {