* replace interface{} with any
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-07-05 09:46:50 +03:00
коммит произвёл GitHub
родитель b45ff0be5d
Коммит 717a4d04a9
258 изменённых файлов: 1286 добавлений и 1286 удалений

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

@@ -10,12 +10,12 @@ import (
// ErrInvalidInput indicates an error that has occurred due to an invalid input.
type ErrInvalidInput struct {
Entity string // The entity which was sent as the input.
Field string // The field of the entity which was invalid.
Value interface{} // The actual value of the field.
Entity string // The entity which was sent as the input.
Field string // The field of the entity which was invalid.
Value any // The actual value of the field.
}
func NewErrInvalidInput(entity, field string, value interface{}) *ErrInvalidInput {
func NewErrInvalidInput(entity, field string, value any) *ErrInvalidInput {
return &ErrInvalidInput{
Entity: entity,
Field: field,
@@ -27,7 +27,7 @@ func (e *ErrInvalidInput) Error() string {
return fmt.Sprintf("invalid input: entity: %s field: %s value: %s", e.Entity, e.Field, e.Value)
}
func (e *ErrInvalidInput) InvalidInputInfo() (entity string, field string, value interface{}) {
func (e *ErrInvalidInput) InvalidInputInfo() (entity string, field string, value any) {
entity = e.Entity
field = e.Field
value = e.Value

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

@@ -408,11 +408,11 @@ func (s *LocalCacheStore) doInvalidateCacheCluster(cache cache.Cache, key string
}
}
func (s *LocalCacheStore) doStandardAddToCache(cache cache.Cache, key string, value interface{}) {
func (s *LocalCacheStore) doStandardAddToCache(cache cache.Cache, key string, value any) {
cache.SetWithDefaultExpiry(key, value)
}
func (s *LocalCacheStore) doStandardReadCache(cache cache.Cache, key string, value interface{}) error {
func (s *LocalCacheStore) doStandardReadCache(cache cache.Cache, key string, value any) error {
err := cache.Get(key, value)
if err == nil {
if s.metrics != nil {

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

@@ -51,7 +51,7 @@ func (str jsonKeyPath) Value() (driver.Value, error) {
type TraceOnAdapter struct{}
func (t *TraceOnAdapter) Printf(format string, v ...interface{}) {
func (t *TraceOnAdapter) Printf(format string, v ...any) {
originalString := fmt.Sprintf(format, v...)
newString := strings.ReplaceAll(originalString, "\n", " ")
newString = strings.ReplaceAll(newString, "\t", " ")

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

@@ -96,7 +96,7 @@ func (us SqlBotStore) GetAll(options *model.BotGetOptions) ([]*model.Bot, error)
var conditions []string
var conditionsSql string
var additionalJoin string
var args []interface{}
var args []any
if !options.IncludeDeleted {
conditions = append(conditions, "b.DeleteAt = 0")

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

@@ -201,7 +201,7 @@ func (s SqlChannelMemberHistoryStore) DeleteOrphanedRows(limit int) (deleted int
func (s SqlChannelMemberHistoryStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
var (
query string
args []interface{}
args []any
err error
)

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

@@ -56,8 +56,8 @@ type channelMember struct {
MsgCountRoot int64
}
func NewMapFromChannelMemberModel(cm *model.ChannelMember) map[string]interface{} {
return map[string]interface{}{
func NewMapFromChannelMemberModel(cm *model.ChannelMember) map[string]any {
return map[string]any{
"ChannelId": cm.ChannelId,
"UserId": cm.UserId,
"Roles": cm.ExplicitRoles,
@@ -109,8 +109,8 @@ func channelMemberSliceColumns() []string {
return []string{"ChannelId", "UserId", "Roles", "LastViewedAt", "MsgCount", "MsgCountRoot", "MentionCount", "MentionCountRoot", "NotifyProps", "LastUpdateAt", "SchemeUser", "SchemeAdmin", "SchemeGuest"}
}
func channelMemberToSlice(member *model.ChannelMember) []interface{} {
resultSlice := []interface{}{}
func channelMemberToSlice(member *model.ChannelMember) []any {
resultSlice := []any{}
resultSlice = append(resultSlice, member.ChannelId)
resultSlice = append(resultSlice, member.UserId)
resultSlice = append(resultSlice, member.ExplicitRoles)
@@ -504,7 +504,7 @@ func (s SqlChannelStore) upsertPublicChannelT(transaction *sqlxTxWrapper, channe
return nil
}
vals := map[string]interface{}{
vals := map[string]any{
"id": publicChannel.Id,
"deleteat": publicChannel.DeleteAt,
"teamid": publicChannel.TeamId,
@@ -752,7 +752,7 @@ func (s SqlChannelStore) updateChannelT(transaction *sqlxTxWrapper, channel *mod
if err != nil {
if IsUniqueConstraintError(err, []string{"Name", "channels_name_teamid_key"}) {
dupChannel := model.Channel{}
s.GetReplicaX().Get(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name= :Name AND DeleteAt > 0", map[string]interface{}{"TeamId": channel.TeamId, "Name": channel.Name})
s.GetReplicaX().Get(&dupChannel, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Name= :Name AND DeleteAt > 0", map[string]any{"TeamId": channel.TeamId, "Name": channel.Name})
if dupChannel.DeleteAt > 0 {
return nil, store.NewErrInvalidInput("Channel", "Id", channel.Id)
}
@@ -1356,7 +1356,7 @@ func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, lim
}
func (s SqlChannelStore) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (model.ChannelList, error) {
props := make(map[string]interface{})
props := make(map[string]any)
props["teamId"] = teamId
idQuery := ""
@@ -2581,7 +2581,7 @@ func (s SqlChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post, userID s
unreadRoot = 0
}
params := map[string]interface{}{
params := map[string]any{
"mentions": mentionCount,
"mentionsroot": mentionCountRoot,
"unreadcount": unread,
@@ -3035,7 +3035,7 @@ func (s SqlChannelStore) AutocompleteInTeamForSearch(teamID string, userID strin
var (
channels = model.ChannelList{}
sql string
args []interface{}
args []any
)
// build the like clause
@@ -3302,7 +3302,7 @@ func (s SqlChannelStore) channelSearchQuery(opts *store.ChannelSearchOpts) sq.Se
if likeTerm != "" {
// Keep the number of likeTerms same as the number of columns
// (c.Name, c.DisplayName, c.Purpose, c.Id?)
likeTerms := make([]interface{}, len(strings.Split(likeFields, ",")))
likeTerms := make([]any, len(strings.Split(likeFields, ",")))
for i := 0; i < len(likeTerms); i++ {
likeTerms[i] = likeTerm
}
@@ -4157,7 +4157,7 @@ func (s SqlChannelStore) GetTeamForChannel(channelID string) (*model.Team, error
// b) those that are public channels in the given team.
func (s SqlChannelStore) GetTopChannelsForTeamSince(teamID string, userID string, since int64, offset int, limit int) (*model.TopChannelList, error) {
channels := make([]*model.TopChannel, 0)
var args []interface{}
var args []any
postgresPropQuery := `AND (Posts.Props ->> 'from_bot' IS NULL OR Posts.Props ->> 'from_bot' = 'false')`
mySqlPropsQuery := `AND (JSON_EXTRACT(Posts.Props, '$.from_bot') IS NULL OR JSON_EXTRACT(Posts.Props, '$.from_bot') = 'false')`
@@ -4185,7 +4185,7 @@ func (s SqlChannelStore) GetTopChannelsForTeamSince(teamID string, userID string
Posts.DeleteAt = 0
AND Posts.CreateAt > ?
AND Posts.Type = ''`
args = []interface{}{since}
args = []any{since}
if s.DriverName() == model.DatabaseDriverMysql {
query += mySqlPropsQuery
@@ -4257,7 +4257,7 @@ func (s SqlChannelStore) GetTopChannelsForTeamSince(teamID string, userID string
// after the given timestamp within the given team (or across the workspace if no team is given). Excludes DM and GM channels.
func (s SqlChannelStore) GetTopChannelsForUserSince(userID string, teamID string, since int64, offset int, limit int) (*model.TopChannelList, error) {
channels := make([]*model.TopChannel, 0)
var args []interface{}
var args []any
var query string
query = `
@@ -4281,7 +4281,7 @@ func (s SqlChannelStore) GetTopChannelsForUserSince(userID string, teamID string
AND (Channels.Type = 'O' OR Channels.Type = 'P')
AND ChannelMembers.UserId = ?`
args = []interface{}{since, userID, userID}
args = []any{since, userID, userID}
if teamID != "" {
query += `

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

@@ -17,7 +17,7 @@ import (
// dbSelecter is an interface used to enable some internal store methods
// using both transaction and normal queries.
type dbSelecter interface {
Select(i interface{}, query string, args ...interface{}) error
Select(i any, query string, args ...any) error
}
func (s SqlChannelStore) CreateInitialSidebarCategories(userId string, opts *store.SidebarCategorySearchOpts) (*model.OrderedSidebarCategories, error) {
@@ -177,7 +177,7 @@ type userMembership struct {
CategoryId string
}
func (s SqlChannelStore) migrateMembershipToSidebar(transaction *sqlxTxWrapper, runningOrder *int64, sql string, args ...interface{}) ([]userMembership, error) {
func (s SqlChannelStore) migrateMembershipToSidebar(transaction *sqlxTxWrapper, runningOrder *int64, sql string, args ...any) ([]userMembership, error) {
memberships := []userMembership{}
if err := transaction.Select(&memberships, sql, args...); err != nil {
return nil, err
@@ -244,7 +244,7 @@ func (s SqlChannelStore) migrateFavoritesToSidebarT(transaction *sqlxTxWrapper,
// MigrateFavoritesToSidebarChannels populates the SidebarChannels table by analyzing existing user preferences for favorites
// **IMPORTANT** This function should only be called from the migration task and shouldn't be used by itself
func (s SqlChannelStore) MigrateFavoritesToSidebarChannels(lastUserId string, runningOrder int64) (map[string]interface{}, error) {
func (s SqlChannelStore) MigrateFavoritesToSidebarChannels(lastUserId string, runningOrder int64) (map[string]any, error) {
transaction, err := s.GetMasterX().Beginx()
if err != nil {
return nil, err
@@ -280,7 +280,7 @@ func (s SqlChannelStore) MigrateFavoritesToSidebarChannels(lastUserId string, ru
return nil, nil
}
data := make(map[string]interface{})
data := make(map[string]any)
data["UserId"] = userFavorites[len(userFavorites)-1].UserId
data["SortOrder"] = runningOrder
return data, nil
@@ -370,7 +370,7 @@ func (s SqlChannelStore) CreateSidebarCategory(userId, teamId string, newCategor
AND SidebarCategories.TeamId = ?`
}
args := []interface{}{userId}
args := []any{userId}
args = append(args, channelIdArgs...)
args = append(args, teamId)
_, err = transaction.Exec(deleteQuery, args...)

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

@@ -106,7 +106,7 @@ func (s SqlComplianceStore) Get(id string) (*model.Compliance, error) {
func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model.ComplianceExportCursor, limit int) ([]*model.CompliancePost, model.ComplianceExportCursor, error) {
keywordQuery := ""
var argsKeywords []interface{}
var argsKeywords []any
keywords := strings.Fields(strings.TrimSpace(strings.ToLower(strings.Replace(job.Keywords, ",", " ", -1))))
if len(keywords) > 0 {
clauses := make([]string, len(keywords))
@@ -121,7 +121,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
}
emailQuery := ""
var argsEmails []interface{}
var argsEmails []any
emails := strings.Fields(strings.TrimSpace(strings.ToLower(strings.Replace(job.Emails, ",", " ", -1))))
if len(emails) > 0 {
clauses := make([]string, len(emails))
@@ -139,7 +139,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
channelPosts := []*model.CompliancePost{}
channelsQuery := ""
var argsChannelsQuery []interface{}
var argsChannelsQuery []any
if !cursor.ChannelsQueryCompleted {
if cursor.LastChannelsQueryPostCreateAt == 0 {
cursor.LastChannelsQueryPostCreateAt = job.StartAt
@@ -204,7 +204,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
directMessagePosts := []*model.CompliancePost{}
directMessagesQuery := ""
var argsDirectMessagesQuery []interface{}
var argsDirectMessagesQuery []any
if !cursor.DirectMessagesQueryCompleted && len(channelPosts) < limit {
if cursor.LastDirectMessagesQueryPostCreateAt == 0 {
cursor.LastDirectMessagesQueryPostCreateAt = job.StartAt
@@ -271,7 +271,7 @@ func (s SqlComplianceStore) ComplianceExport(job *model.Compliance, cursor model
}
func (s SqlComplianceStore) MessageExport(cursor model.MessageExportCursor, limit int) ([]*model.MessageExport, model.MessageExportCursor, error) {
var args []interface{}
var args []any
args = append(args, model.ChannelTypeDirect, model.ChannelTypeGroup, cursor.LastPostUpdateAt, cursor.LastPostUpdateAt, cursor.LastPostId, limit)
query :=
`SELECT

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

@@ -168,7 +168,7 @@ func (fs SqlFileInfoStore) Upsert(info *model.FileInfo) (*model.FileInfo, error)
queryString, args, err := fs.getQueryBuilder().
Update("FileInfo").
SetMap(map[string]interface{}{
SetMap(map[string]any{
"UpdateAt": info.UpdateAt,
"DeleteAt": info.DeleteAt,
"Path": info.Path,

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

@@ -199,7 +199,7 @@ func (s *SqlGroupStore) checkUsersExist(userIDs []string) error {
return nil
}
func (s *SqlGroupStore) buildInsertGroupUsersQuery(groupId string, userIds []string) (query string, args []interface{}, err error) {
func (s *SqlGroupStore) buildInsertGroupUsersQuery(groupId string, userIds []string) (query string, args []any, err error) {
if len(userIds) > 0 {
builder := s.getQueryBuilder().
Insert("GroupMembers").
@@ -631,7 +631,7 @@ func (s *SqlGroupStore) GetGroupSyncable(groupID string, syncableID string, sync
func (s *SqlGroupStore) getGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, error) {
var err error
var result interface{}
var result any
switch syncableType {
case model.GroupSyncableTypeTeam:
@@ -1768,7 +1768,7 @@ func (s *SqlGroupStore) countTable(tableName string) (int64, error) {
return s.countTableWithSelectAndWhere("COUNT(*)", tableName, nil)
}
func (s *SqlGroupStore) countTableWithSelectAndWhere(selectStr, tableName string, whereStmt map[string]interface{}) (int64, error) {
func (s *SqlGroupStore) countTableWithSelectAndWhere(selectStr, tableName string, whereStmt map[string]any) (int64, error) {
if whereStmt == nil {
whereStmt = sq.Eq{"DeleteAt": 0}
}
@@ -1802,7 +1802,7 @@ func (s *SqlGroupStore) UpsertMembers(groupID string, userIDs []string) ([]*mode
return members, err
}
func (s *SqlGroupStore) buildUpsertMembersQuery(groupID string, userIDs []string) (members []*model.GroupMember, query string, args []interface{}, err error) {
func (s *SqlGroupStore) buildUpsertMembersQuery(groupID string, userIDs []string) (members []*model.GroupMember, query string, args []any, err error) {
var retrievedGroup model.Group
// Check Group exists
if err = s.GetReplicaX().Get(&retrievedGroup, "SELECT * FROM UserGroups WHERE Id = ?", groupID); err != nil {
@@ -1854,7 +1854,7 @@ func (s *SqlGroupStore) DeleteMembers(groupID string, userIDs []string) ([]*mode
return members, err
}
func (s *SqlGroupStore) buildDeleteMembersQuery(groupID string, userIDs []string) (members []*model.GroupMember, query string, args []interface{}, err error) {
func (s *SqlGroupStore) buildDeleteMembersQuery(groupID string, userIDs []string) (members []*model.GroupMember, query string, args []any, err error) {
membersSelectQuery, membersSelectArgs, err := s.getQueryBuilder().
Select("*").
From("GroupMembers").

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

@@ -17,7 +17,7 @@ type relationalCheckConfig struct {
childIdAttr string
canParentIdBeEmpty bool
sortRecords bool
filter interface{}
filter any
}
func getOrphanedRecords(ss *SqlStore, cfg relationalCheckConfig) ([]model.OrphanedRecord, error) {

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

@@ -71,8 +71,8 @@ func postSliceColumnsWithTypes() []struct {
}
}
func postToSlice(post *model.Post) []interface{} {
return []interface{}{
func postToSlice(post *model.Post) []any {
return []any{
post.Id,
post.CreateAt,
post.UpdateAt,
@@ -233,7 +233,7 @@ func (s *SqlPostStore) SaveMultiple(posts []*model.Post) ([]*model.Post, int, er
LastRootPostAt = GREATEST(:lastrootpostat, LastRootPostAt),
TotalMsgCount = TotalMsgCount + :count,
TotalMsgCountRoot = TotalMsgCountRoot + :countroot
WHERE Id = :channelid`, map[string]interface{}{
WHERE Id = :channelid`, map[string]any{
"lastpostat": maxDateNewPosts[channelId],
"lastrootpostat": maxDateNewRootPosts[channelId],
"channelid": channelId,
@@ -508,7 +508,7 @@ func (s *SqlPostStore) getFlaggedPosts(userId, channelId, teamId string, offset
ORDER BY CreateAt DESC
LIMIT ? OFFSET ?`
queryParams := []interface{}{userId, model.PreferenceCategoryFlaggedPost}
queryParams := []any{userId, model.PreferenceCategoryFlaggedPost}
var channelClause, teamClause string
channelClause, queryParams = s.buildFlaggedPostChannelFilterClause(channelId, queryParams)
@@ -533,7 +533,7 @@ func (s *SqlPostStore) getFlaggedPosts(userId, channelId, teamId string, offset
return pl, nil
}
func (s *SqlPostStore) buildFlaggedPostTeamFilterClause(teamId string, queryParams []interface{}) (string, []interface{}) {
func (s *SqlPostStore) buildFlaggedPostTeamFilterClause(teamId string, queryParams []any) (string, []any) {
if teamId == "" {
return "", queryParams
}
@@ -541,7 +541,7 @@ func (s *SqlPostStore) buildFlaggedPostTeamFilterClause(teamId string, queryPara
return "AND B.TeamId = ? OR B.TeamId = ''", append(queryParams, teamId)
}
func (s *SqlPostStore) buildFlaggedPostChannelFilterClause(channelId string, queryParams []interface{}) (string, []interface{}) {
func (s *SqlPostStore) buildFlaggedPostChannelFilterClause(channelId string, queryParams []any) (string, []any) {
if channelId == "" {
return "", queryParams
}
@@ -930,7 +930,7 @@ func (s *SqlPostStore) permanentDelete(postId string) error {
return errors.Wrapf(err, "failed to cleanup threads for Post with id=%s", postId)
}
if _, err = transaction.NamedExec("DELETE FROM Posts WHERE Id = :id OR RootId = :rootid", map[string]interface{}{"id": postId, "rootid": postId}); err != nil {
if _, err = transaction.NamedExec("DELETE FROM Posts WHERE Id = :id OR RootId = :rootid", map[string]any{"id": postId, "rootid": postId}); err != nil {
return errors.Wrapf(err, "failed to delete Post with id=%s", postId)
}
@@ -1250,7 +1250,7 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
replyCountQuery2 = `, (SELECT COUNT(*) FROM Posts WHERE Posts.RootId = (CASE WHEN cte.RootId = '' THEN cte.Id ELSE cte.RootId END) AND Posts.DeleteAt = 0) as ReplyCount`
}
var query string
var params []interface{}
var params []any
// union of IDs and then join to get full posts is faster in mysql
if s.DriverName() == model.DatabaseDriverMysql {
@@ -1282,7 +1282,7 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
) j ON p1.Id = j.Id
ORDER BY CreateAt ` + order
params = []interface{}{options.Time, options.ChannelId, options.Time, options.ChannelId}
params = []any{options.Time, options.ChannelId, options.Time, options.ChannelId}
} else if s.DriverName() == model.DatabaseDriverPostgres {
query = `WITH cte AS (SELECT
*
@@ -1296,7 +1296,7 @@ func (s *SqlPostStore) GetPostsSince(options model.GetPostsSinceOptions, allowFr
(SELECT *` + replyCountQuery1 + ` FROM Posts p1 WHERE id in (SELECT rootid FROM cte))
ORDER BY CreateAt ` + order
params = []interface{}{options.Time, options.ChannelId}
params = []any{options.Time, options.ChannelId}
}
err := s.GetReplicaX().Select(&posts, query, params...)
if err != nil {
@@ -2029,7 +2029,7 @@ func removeMysqlStopWordsFromTerms(terms string) (string, error) {
// TODO: convert to squirrel HW
func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.AnalyticsRows, error) {
var args []interface{}
var args []any
query :=
`SELECT DISTINCT
DATE(FROM_UNIXTIME(Posts.CreateAt / 1000)) AS Name,
@@ -2038,7 +2038,7 @@ func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.A
if teamId != "" {
query += " INNER JOIN Channels ON Posts.ChannelId = Channels.Id AND Channels.TeamId = ? AND"
args = []interface{}{teamId}
args = []any{teamId}
} else {
query += " WHERE"
}
@@ -2056,7 +2056,7 @@ func (s *SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) (model.A
if teamId != "" {
query += " INNER JOIN Channels ON Posts.ChannelId = Channels.Id AND Channels.TeamId = ? AND"
args = []interface{}{teamId}
args = []any{teamId}
} else {
query += " WHERE"
}
@@ -2085,7 +2085,7 @@ 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 []interface{}
var args []any
query :=
`SELECT
DATE(FROM_UNIXTIME(Posts.CreateAt / 1000)) AS Name,
@@ -2098,7 +2098,7 @@ func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCoun
if options.TeamId != "" {
query += " INNER JOIN Channels ON Posts.ChannelId = Channels.Id AND Channels.TeamId = ? AND"
args = []interface{}{options.TeamId}
args = []any{options.TeamId}
} else {
query += " WHERE"
}
@@ -2121,7 +2121,7 @@ func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCoun
if options.TeamId != "" {
query += " INNER JOIN Channels ON Posts.ChannelId = Channels.Id AND Channels.TeamId = ? AND"
args = []interface{}{options.TeamId}
args = []any{options.TeamId}
} else {
query += " WHERE"
}

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

@@ -296,7 +296,7 @@ func (s *SqlReactionStore) GetTopForTeamSince(teamID string, userID string, sinc
// b) those created by the given user in DM or group channels.
func (s *SqlReactionStore) GetTopForUserSince(userID string, teamID string, since int64, offset int, limit int) (*model.TopReactionList, error) {
reactions := make([]*model.TopReaction, 0)
var args []interface{}
var args []any
var query string
if teamID != "" {
@@ -320,7 +320,7 @@ func (s *SqlReactionStore) GetTopForUserSince(userID string, teamID string, sinc
EmojiName ASC
LIMIT ?
OFFSET ?`
args = []interface{}{userID, teamID, since, limit + 1, offset}
args = []any{userID, teamID, since, limit + 1, offset}
} else {
query = `
SELECT
@@ -339,7 +339,7 @@ func (s *SqlReactionStore) GetTopForUserSince(userID string, teamID string, sinc
EmojiName ASC
LIMIT ?
OFFSET ?`
args = []interface{}{userID, since, limit + 1, offset}
args = []any{userID, since, limit + 1, offset}
}
if err := s.GetReplicaX().Select(&reactions, query, args...); err != nil {

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

@@ -32,7 +32,7 @@ func newSqlRetentionPolicyStore(sqlStore *SqlStore, metrics einterfaces.MetricsI
// executePossiblyEmptyQuery only executes the query if it is non-empty. This helps avoid
// having to check for MySQL, which, unlike Postgres, does not allow empty queries.
func executePossiblyEmptyQuery(txn *sqlxTxWrapper, query string, args ...interface{}) (sql.Result, error) {
func executePossiblyEmptyQuery(txn *sqlxTxWrapper, query string, args ...any) (sql.Result, error) {
if query == "" {
return nil, nil
}
@@ -169,7 +169,7 @@ func (s *SqlRetentionPolicyStore) checkChannelsExist(channelIDs []string) error
return nil
}
func (s *SqlRetentionPolicyStore) buildInsertRetentionPoliciesChannelsQuery(policyID string, channelIDs []string) (query string, args []interface{}, err error) {
func (s *SqlRetentionPolicyStore) buildInsertRetentionPoliciesChannelsQuery(policyID string, channelIDs []string) (query string, args []any, err error) {
if len(channelIDs) > 0 {
builder := s.getQueryBuilder().
Insert("RetentionPoliciesChannels").
@@ -182,7 +182,7 @@ func (s *SqlRetentionPolicyStore) buildInsertRetentionPoliciesChannelsQuery(poli
return
}
func (s *SqlRetentionPolicyStore) buildInsertRetentionPoliciesTeamsQuery(policyID string, teamIDs []string) (query string, args []interface{}, err error) {
func (s *SqlRetentionPolicyStore) buildInsertRetentionPoliciesTeamsQuery(policyID string, teamIDs []string) (query string, args []any, err error) {
if len(teamIDs) > 0 {
builder := s.getQueryBuilder().
Insert("RetentionPoliciesTeams").
@@ -213,7 +213,7 @@ func (s *SqlRetentionPolicyStore) Patch(patch *model.RetentionPolicyWithTeamAndC
}
policyUpdateQuery := ""
policyUpdateArgs := []interface{}{}
policyUpdateArgs := []any{}
if patch.DisplayName != "" || patch.PostDurationDays != nil {
builder := s.getQueryBuilder().Update("RetentionPolicies")
if patch.DisplayName != "" {
@@ -231,9 +231,9 @@ func (s *SqlRetentionPolicyStore) Patch(patch *model.RetentionPolicyWithTeamAndC
}
channelsDeleteQuery := ""
channelsDeleteArgs := []interface{}{}
channelsDeleteArgs := []any{}
channelsInsertQuery := ""
channelsInsertArgs := []interface{}{}
channelsInsertArgs := []any{}
if patch.ChannelIDs != nil {
channelsDeleteQuery, channelsDeleteArgs, err = s.getQueryBuilder().
Delete("RetentionPoliciesChannels").
@@ -250,9 +250,9 @@ func (s *SqlRetentionPolicyStore) Patch(patch *model.RetentionPolicyWithTeamAndC
}
teamsDeleteQuery := ""
teamsDeleteArgs := []interface{}{}
teamsDeleteArgs := []any{}
teamsInsertQuery := ""
teamsInsertArgs := []interface{}{}
teamsInsertArgs := []any{}
if patch.TeamIDs != nil {
teamsDeleteQuery, teamsDeleteArgs, err = s.getQueryBuilder().
Delete("RetentionPoliciesTeams").
@@ -309,14 +309,14 @@ func (s *SqlRetentionPolicyStore) Patch(patch *model.RetentionPolicyWithTeamAndC
return &newPolicy, nil
}
func (s *SqlRetentionPolicyStore) buildGetPolicyQuery(id string) (string, []interface{}, error) {
func (s *SqlRetentionPolicyStore) buildGetPolicyQuery(id string) (string, []any, error) {
return s.buildGetPoliciesQuery(id, 0, 1)
}
// buildGetPoliciesQuery builds a query to select information for the policy with the specified
// ID, or, if `id` is the empty string, from all policies. The results returned will be sorted by
// policy display name and ID.
func (s *SqlRetentionPolicyStore) buildGetPoliciesQuery(id string, offset, limit int) (string, []interface{}, error) {
func (s *SqlRetentionPolicyStore) buildGetPoliciesQuery(id string, offset, limit int) (string, []any, error) {
rpcSubQuery := s.getQueryBuilder().
Select("RetentionPolicies.Id, COUNT(RetentionPoliciesChannels.ChannelId) AS Count").
From("RetentionPolicies").

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

@@ -36,23 +36,23 @@ func (w *StoreTestWrapper) DriverName() string {
}
type Builder interface {
ToSql() (string, []interface{}, error)
ToSql() (string, []any, error)
}
// sqlxExecutor exposes sqlx operations. It is used to enable some internal store methods to
// accept both transactions (*sqlxTxWrapper) and common db handlers (*sqlxDbWrapper).
type sqlxExecutor interface {
Get(dest interface{}, query string, args ...interface{}) error
GetBuilder(dest interface{}, builder Builder) error
NamedExec(query string, arg interface{}) (sql.Result, error)
Exec(query string, args ...interface{}) (sql.Result, error)
Get(dest any, query string, args ...any) error
GetBuilder(dest any, builder Builder) error
NamedExec(query string, arg any) (sql.Result, error)
Exec(query string, args ...any) (sql.Result, error)
ExecBuilder(builder Builder) (sql.Result, error)
ExecRaw(query string, args ...interface{}) (sql.Result, error)
NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
QueryRowX(query string, args ...interface{}) *sqlx.Row
QueryX(query string, args ...interface{}) (*sqlx.Rows, error)
Select(dest interface{}, query string, args ...interface{}) error
SelectBuilder(dest interface{}, builder Builder) error
ExecRaw(query string, args ...any) (sql.Result, error)
NamedQuery(query string, arg any) (*sqlx.Rows, error)
QueryRowX(query string, args ...any) *sqlx.Row
QueryX(query string, args ...any) (*sqlx.Rows, error)
Select(dest any, query string, args ...any) error
SelectBuilder(dest any, builder Builder) error
}
// namedParamRegex is used to capture all named parameters and convert them
@@ -98,7 +98,7 @@ func (w *sqlxDBWrapper) BeginXWithIsolation(opts *sql.TxOptions) (*sqlxTxWrapper
return newSqlxTxWrapper(tx, w.queryTimeout, w.trace), nil
}
func (w *sqlxDBWrapper) Get(dest interface{}, query string, args ...interface{}) error {
func (w *sqlxDBWrapper) Get(dest any, query string, args ...any) error {
query = w.DB.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -112,7 +112,7 @@ func (w *sqlxDBWrapper) Get(dest interface{}, query string, args ...interface{})
return w.DB.GetContext(ctx, dest, query, args...)
}
func (w *sqlxDBWrapper) GetBuilder(dest interface{}, builder Builder) error {
func (w *sqlxDBWrapper) GetBuilder(dest any, builder Builder) error {
query, args, err := builder.ToSql()
if err != nil {
return err
@@ -121,7 +121,7 @@ func (w *sqlxDBWrapper) GetBuilder(dest interface{}, builder Builder) error {
return w.Get(dest, query, args...)
}
func (w *sqlxDBWrapper) NamedExec(query string, arg interface{}) (sql.Result, error) {
func (w *sqlxDBWrapper) NamedExec(query string, arg any) (sql.Result, error) {
if w.DB.DriverName() == model.DatabaseDriverPostgres {
query = namedParamRegex.ReplaceAllStringFunc(query, strings.ToLower)
}
@@ -137,7 +137,7 @@ func (w *sqlxDBWrapper) NamedExec(query string, arg interface{}) (sql.Result, er
return w.DB.NamedExecContext(ctx, query, arg)
}
func (w *sqlxDBWrapper) Exec(query string, args ...interface{}) (sql.Result, error) {
func (w *sqlxDBWrapper) Exec(query string, args ...any) (sql.Result, error) {
query = w.DB.Rebind(query)
return w.ExecRaw(query, args...)
@@ -152,7 +152,7 @@ func (w *sqlxDBWrapper) ExecBuilder(builder Builder) (sql.Result, error) {
return w.Exec(query, args...)
}
func (w *sqlxDBWrapper) ExecNoTimeout(query string, args ...interface{}) (sql.Result, error) {
func (w *sqlxDBWrapper) ExecNoTimeout(query string, args ...any) (sql.Result, error) {
query = w.DB.Rebind(query)
if w.trace {
@@ -166,7 +166,7 @@ func (w *sqlxDBWrapper) ExecNoTimeout(query string, args ...interface{}) (sql.Re
// ExecRaw is like Exec but without any rebinding of params. You need to pass
// the exact param types of your target database.
func (w *sqlxDBWrapper) ExecRaw(query string, args ...interface{}) (sql.Result, error) {
func (w *sqlxDBWrapper) ExecRaw(query string, args ...any) (sql.Result, error) {
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -179,7 +179,7 @@ func (w *sqlxDBWrapper) ExecRaw(query string, args ...interface{}) (sql.Result,
return w.DB.ExecContext(ctx, query, args...)
}
func (w *sqlxDBWrapper) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error) {
func (w *sqlxDBWrapper) NamedQuery(query string, arg any) (*sqlx.Rows, error) {
if w.DB.DriverName() == model.DatabaseDriverPostgres {
query = namedParamRegex.ReplaceAllStringFunc(query, strings.ToLower)
}
@@ -195,7 +195,7 @@ func (w *sqlxDBWrapper) NamedQuery(query string, arg interface{}) (*sqlx.Rows, e
return w.DB.NamedQueryContext(ctx, query, arg)
}
func (w *sqlxDBWrapper) QueryRowX(query string, args ...interface{}) *sqlx.Row {
func (w *sqlxDBWrapper) QueryRowX(query string, args ...any) *sqlx.Row {
query = w.DB.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -209,7 +209,7 @@ func (w *sqlxDBWrapper) QueryRowX(query string, args ...interface{}) *sqlx.Row {
return w.DB.QueryRowxContext(ctx, query, args...)
}
func (w *sqlxDBWrapper) QueryX(query string, args ...interface{}) (*sqlx.Rows, error) {
func (w *sqlxDBWrapper) QueryX(query string, args ...any) (*sqlx.Rows, error) {
query = w.DB.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -223,7 +223,7 @@ func (w *sqlxDBWrapper) QueryX(query string, args ...interface{}) (*sqlx.Rows, e
return w.DB.QueryxContext(ctx, query, args)
}
func (w *sqlxDBWrapper) Select(dest interface{}, query string, args ...interface{}) error {
func (w *sqlxDBWrapper) Select(dest any, query string, args ...any) error {
query = w.DB.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -237,7 +237,7 @@ func (w *sqlxDBWrapper) Select(dest interface{}, query string, args ...interface
return w.DB.SelectContext(ctx, dest, query, args...)
}
func (w *sqlxDBWrapper) SelectBuilder(dest interface{}, builder Builder) error {
func (w *sqlxDBWrapper) SelectBuilder(dest any, builder Builder) error {
query, args, err := builder.ToSql()
if err != nil {
return err
@@ -260,7 +260,7 @@ func newSqlxTxWrapper(tx *sqlx.Tx, timeout time.Duration, trace bool) *sqlxTxWra
}
}
func (w *sqlxTxWrapper) Get(dest interface{}, query string, args ...interface{}) error {
func (w *sqlxTxWrapper) Get(dest any, query string, args ...any) error {
query = w.Tx.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -274,7 +274,7 @@ func (w *sqlxTxWrapper) Get(dest interface{}, query string, args ...interface{})
return w.Tx.GetContext(ctx, dest, query, args...)
}
func (w *sqlxTxWrapper) GetBuilder(dest interface{}, builder Builder) error {
func (w *sqlxTxWrapper) GetBuilder(dest any, builder Builder) error {
query, args, err := builder.ToSql()
if err != nil {
return err
@@ -283,13 +283,13 @@ func (w *sqlxTxWrapper) GetBuilder(dest interface{}, builder Builder) error {
return w.Get(dest, query, args...)
}
func (w *sqlxTxWrapper) Exec(query string, args ...interface{}) (sql.Result, error) {
func (w *sqlxTxWrapper) Exec(query string, args ...any) (sql.Result, error) {
query = w.Tx.Rebind(query)
return w.ExecRaw(query, args...)
}
func (w *sqlxTxWrapper) ExecNoTimeout(query string, args ...interface{}) (sql.Result, error) {
func (w *sqlxTxWrapper) ExecNoTimeout(query string, args ...any) (sql.Result, error) {
query = w.Tx.Rebind(query)
if w.trace {
@@ -312,7 +312,7 @@ func (w *sqlxTxWrapper) ExecBuilder(builder Builder) (sql.Result, error) {
// ExecRaw is like Exec but without any rebinding of params. You need to pass
// the exact param types of your target database.
func (w *sqlxTxWrapper) ExecRaw(query string, args ...interface{}) (sql.Result, error) {
func (w *sqlxTxWrapper) ExecRaw(query string, args ...any) (sql.Result, error) {
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -325,7 +325,7 @@ func (w *sqlxTxWrapper) ExecRaw(query string, args ...interface{}) (sql.Result,
return w.Tx.ExecContext(ctx, query, args...)
}
func (w *sqlxTxWrapper) NamedExec(query string, arg interface{}) (sql.Result, error) {
func (w *sqlxTxWrapper) NamedExec(query string, arg any) (sql.Result, error) {
if w.Tx.DriverName() == model.DatabaseDriverPostgres {
query = namedParamRegex.ReplaceAllStringFunc(query, strings.ToLower)
}
@@ -341,7 +341,7 @@ func (w *sqlxTxWrapper) NamedExec(query string, arg interface{}) (sql.Result, er
return w.Tx.NamedExecContext(ctx, query, arg)
}
func (w *sqlxTxWrapper) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error) {
func (w *sqlxTxWrapper) NamedQuery(query string, arg any) (*sqlx.Rows, error) {
if w.Tx.DriverName() == model.DatabaseDriverPostgres {
query = namedParamRegex.ReplaceAllStringFunc(query, strings.ToLower)
}
@@ -385,7 +385,7 @@ func (w *sqlxTxWrapper) NamedQuery(query string, arg interface{}) (*sqlx.Rows, e
return res.rows, res.err
}
func (w *sqlxTxWrapper) QueryRowX(query string, args ...interface{}) *sqlx.Row {
func (w *sqlxTxWrapper) QueryRowX(query string, args ...any) *sqlx.Row {
query = w.Tx.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -399,7 +399,7 @@ func (w *sqlxTxWrapper) QueryRowX(query string, args ...interface{}) *sqlx.Row {
return w.Tx.QueryRowxContext(ctx, query, args...)
}
func (w *sqlxTxWrapper) QueryX(query string, args ...interface{}) (*sqlx.Rows, error) {
func (w *sqlxTxWrapper) QueryX(query string, args ...any) (*sqlx.Rows, error) {
query = w.Tx.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -413,7 +413,7 @@ func (w *sqlxTxWrapper) QueryX(query string, args ...interface{}) (*sqlx.Rows, e
return w.Tx.QueryxContext(ctx, query, args)
}
func (w *sqlxTxWrapper) Select(dest interface{}, query string, args ...interface{}) error {
func (w *sqlxTxWrapper) Select(dest any, query string, args ...any) error {
query = w.Tx.Rebind(query)
ctx, cancel := context.WithTimeout(context.Background(), w.queryTimeout)
defer cancel()
@@ -427,7 +427,7 @@ func (w *sqlxTxWrapper) Select(dest interface{}, query string, args ...interface
return w.Tx.SelectContext(ctx, dest, query, args...)
}
func (w *sqlxTxWrapper) SelectBuilder(dest interface{}, builder Builder) error {
func (w *sqlxTxWrapper) SelectBuilder(dest any, builder Builder) error {
query, args, err := builder.ToSql()
if err != nil {
return err
@@ -446,7 +446,7 @@ func removeSpace(r rune) rune {
return r
}
func printArgs(query string, dur time.Duration, args ...interface{}) {
func printArgs(query string, dur time.Duration, args ...any) {
query = strings.Map(removeSpace, query)
fields := make([]mlog.Field, 0, len(args)+1)
fields = append(fields, mlog.Duration("duration", dur))

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

@@ -68,8 +68,8 @@ func teamMemberSliceColumns() []string {
return []string{"TeamId", "UserId", "Roles", "DeleteAt", "SchemeUser", "SchemeAdmin", "SchemeGuest"}
}
func teamMemberToSlice(member *model.TeamMember) []interface{} {
resultSlice := []interface{}{}
func teamMemberToSlice(member *model.TeamMember) []any {
resultSlice := []any{}
resultSlice = append(resultSlice, member.TeamId)
resultSlice = append(resultSlice, member.UserId)
resultSlice = append(resultSlice, member.ExplicitRoles)
@@ -1579,11 +1579,11 @@ func applyTeamMemberViewRestrictionsFilter(query sq.SelectBuilder, restrictions
return query.Where("1 = 0")
}
teams := make([]interface{}, len(restrictions.Teams))
teams := make([]any, len(restrictions.Teams))
for i, v := range restrictions.Teams {
teams[i] = v
}
channels := make([]interface{}, len(restrictions.Channels))
channels := make([]any, len(restrictions.Channels))
for i, v := range restrictions.Channels {
channels[i] = v
}
@@ -1609,11 +1609,11 @@ func applyTeamMemberViewRestrictionsFilterForStats(query sq.SelectBuilder, restr
return query.Where("1 = 0")
}
teams := make([]interface{}, len(restrictions.Teams))
teams := make([]any, len(restrictions.Teams))
for i, v := range restrictions.Teams {
teams[i] = v
}
channels := make([]interface{}, len(restrictions.Channels))
channels := make([]any, len(restrictions.Channels))
for i, v := range restrictions.Channels {
channels[i] = v
}

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

@@ -938,7 +938,7 @@ func (s *SqlThreadStore) GetThreadUnreadReplyCount(threadMembership *model.Threa
// Top threads in all public channels and private channels userID is a member of. Returns a list of threads ranked by interactions.
func (s *SqlThreadStore) GetTopThreadsForTeamSince(teamID string, userID string, since int64, offset int, limit int) (*model.TopThreadList, error) {
var args []interface{}
var args []any
query := `select
threads_list.PostId,
threads_list.ReplyCount,
@@ -1012,7 +1012,7 @@ func (s *SqlThreadStore) GetTopThreadsForTeamSince(teamID string, userID string,
}
func (s *SqlThreadStore) GetTopThreadsForUserSince(teamID string, userID string, since int64, offset int, limit int) (*model.TopThreadList, error) {
var args []interface{}
var args []any
// gets all threads within the team which user follows.
query := `select

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

@@ -174,7 +174,7 @@ func (s SqlUserAccessTokenStore) GetByUser(userId string, offset, limit int) ([]
func (s SqlUserAccessTokenStore) Search(term string) ([]*model.UserAccessToken, error) {
term = sanitizeSearchTerm(term, "\\")
tokens := []*model.UserAccessToken{}
params := []interface{}{term, term, term}
params := []any{term, term, term}
query := `
SELECT
uat.*

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

@@ -932,7 +932,7 @@ func (us SqlUserStore) GetProfilesByUsernames(usernames []string, viewRestrictio
query = applyViewRestrictionsFilter(query, viewRestrictions, true)
query = query.
Where(map[string]interface{}{
Where(map[string]any{
"Username": usernames,
}).
OrderBy("u.Username ASC")
@@ -1021,13 +1021,13 @@ func (us SqlUserStore) GetProfileByIds(ctx context.Context, userIds []string, op
users := []*model.User{}
query := us.usersQuery.
Where(map[string]interface{}{
Where(map[string]any{
"u.Id": userIds,
}).
OrderBy("u.Username ASC")
if options.Since > 0 {
query = query.Where(sq.Gt(map[string]interface{}{
query = query.Where(sq.Gt(map[string]any{
"u.UpdateAt": options.Since,
}))
}
@@ -1499,7 +1499,7 @@ func (us SqlUserStore) SearchNotInGroup(groupID string, term string, options *mo
func generateSearchQuery(query sq.SelectBuilder, terms []string, fields []string, isPostgreSQL bool) sq.SelectBuilder {
for _, term := range terms {
searchFields := []string{}
termArgs := []interface{}{}
termArgs := []any{}
for _, field := range fields {
if isPostgreSQL {
searchFields = append(searchFields, fmt.Sprintf("lower(%s) LIKE lower(?) escape '*' ", field))
@@ -1859,11 +1859,11 @@ func applyViewRestrictionsFilter(query sq.SelectBuilder, restrictions *model.Vie
return query.Where("1 = 0")
}
teams := make([]interface{}, len(restrictions.Teams))
teams := make([]any, len(restrictions.Teams))
for i, v := range restrictions.Teams {
teams[i] = v
}
channels := make([]interface{}, len(restrictions.Channels))
channels := make([]any, len(restrictions.Channels))
for i, v := range restrictions.Channels {
channels[i] = v
}

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

@@ -33,9 +33,9 @@ func sanitizeSearchTerm(term string, escapeChar string) string {
// Converts a list of strings into a list of query parameters and a named parameter map that can
// be used as part of a SQL query.
func MapStringsToQueryParams(list []string, paramPrefix string) (string, map[string]interface{}) {
func MapStringsToQueryParams(list []string, paramPrefix string) (string, map[string]any) {
var keys strings.Builder
params := make(map[string]interface{}, len(list))
params := make(map[string]any, len(list))
for i, entry := range list {
if keys.Len() > 0 {
keys.WriteString(",")
@@ -99,13 +99,13 @@ func isQuotedWord(s string) bool {
// SET Col = JSON_SET(Col, `+argString+`)
// WHERE Id=?`, args...)
// after appending the Id param to the args slice.
func constructMySQLJSONArgs(props map[string]string) ([]interface{}, string) {
func constructMySQLJSONArgs(props map[string]string) ([]any, string) {
if len(props) == 0 {
return nil, ""
}
// Unpack the keys and values to pass to MySQL.
args := make([]interface{}, 0, len(props))
args := make([]any, 0, len(props))
for k, v := range props {
args = append(args, "$."+k, v)
}
@@ -118,17 +118,17 @@ func constructMySQLJSONArgs(props map[string]string) ([]interface{}, string) {
return args, argString
}
func makeStringArgs(params []string) []interface{} {
args := make([]interface{}, len(params))
func makeStringArgs(params []string) []any {
args := make([]any, len(params))
for i, name := range params {
args[i] = name
}
return args
}
func constructArrayArgs(ids []string) (string, []interface{}) {
func constructArrayArgs(ids []string) (string, []any) {
var placeholder strings.Builder
values := make([]interface{}, 0, len(ids))
values := make([]any, 0, len(ids))
for _, entry := range ids {
if placeholder.Len() > 0 {
placeholder.WriteString(",")

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

@@ -35,7 +35,7 @@ func TestMapStringsToQueryParams(t *testing.T) {
}
var keys string
var params map[string]interface{}
var params map[string]any
func BenchmarkMapStringsToQueryParams(b *testing.B) {
b.Run("one item", func(b *testing.B) {
@@ -108,7 +108,7 @@ func TestRemoveNonAlphaNumericUnquotedTerms(t *testing.T) {
func TestMySQLJSONArgs(t *testing.T) {
tests := []struct {
props map[string]string
args []interface{}
args []any
argString string
}{
{
@@ -117,7 +117,7 @@ func TestMySQLJSONArgs(t *testing.T) {
"mobile": "android",
"notify": "always",
},
args: []interface{}{"$.desktop", "linux", "$.mobile", "android", "$.notify", "always"},
args: []any{"$.desktop", "linux", "$.mobile", "android", "$.notify", "always"},
argString: "?, ?, ?, ?, ?, ?",
},
{

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

@@ -14,7 +14,7 @@ import (
)
type StoreResult struct {
Data interface{}
Data any
// NErr a temporary field used by the new code for the AppError migration. This will later become Err when the entire store is migrated.
NErr error

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

@@ -30,14 +30,14 @@ type SqlStore interface {
}
type SqlXExecutor interface {
Get(dest interface{}, query string, args ...interface{}) error
NamedExec(query string, arg interface{}) (sql.Result, error)
Exec(query string, args ...interface{}) (sql.Result, error)
ExecRaw(query string, args ...interface{}) (sql.Result, error)
NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
QueryRowX(query string, args ...interface{}) *sqlx.Row
QueryX(query string, args ...interface{}) (*sqlx.Rows, error)
Select(dest interface{}, query string, args ...interface{}) error
Get(dest any, query string, args ...any) error
NamedExec(query string, arg any) (sql.Result, error)
Exec(query string, args ...any) (sql.Result, error)
ExecRaw(query string, args ...any) (sql.Result, error)
NamedQuery(query string, arg any) (*sqlx.Rows, error)
QueryRowX(query string, args ...any) *sqlx.Row
QueryX(query string, args ...any) (*sqlx.Rows, error)
Select(dest any, query string, args ...any) error
}
func cleanupChannels(t *testing.T, ss store.Store) {
@@ -7337,7 +7337,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) {
PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
VALUES
(:id, :deleteat, :teamid, :displayname, :name, :header, :purpose);
`, map[string]interface{}{
`, map[string]any{
"id": o3.Id,
"deleteat": o3.DeleteAt,
"teamid": o3.TeamId,
@@ -7355,7 +7355,7 @@ func testMaterializedPublicChannels(t *testing.T, ss store.Store, s SqlStore) {
Channels(Id, CreateAt, UpdateAt, DeleteAt, TeamId, Type, DisplayName, Name, Header, Purpose, LastPostAt, LastRootPostAt, TotalMsgCount, ExtraUpdateAt, CreatorId, TotalMsgCountRoot)
VALUES
(:id, :createat, :updateat, :deleteat, :teamid, :type, :displayname, :name, :header, :purpose, :lastpostat, :lastrootpostat, :totalmsgcount, :extraupdateat, :creatorid, 0);
`, map[string]interface{}{
`, map[string]any{
"id": o3.Id,
"createat": o3.CreateAt,
"updateat": o3.UpdateAt,

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

@@ -1050,7 +1050,7 @@ func testDeleteExportMessage(t *testing.T, ss store.Store) {
assert.Equal(t, postDeleteTime, *v.PostUpdateAt)
assert.NotNil(t, v.PostProps)
props := map[string]interface{}{}
props := map[string]any{}
e := json.Unmarshal([]byte(*v.PostProps), &props)
require.NoError(t, e)
@@ -1153,7 +1153,7 @@ func testDeleteAfterExportMessage(t *testing.T, ss store.Store) {
assert.Equal(t, postDeleteTime, *v.PostUpdateAt)
assert.NotNil(t, v.PostProps)
props := map[string]interface{}{}
props := map[string]any{}
e := json.Unmarshal([]byte(*v.PostProps), &props)
require.NoError(t, e)

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

@@ -383,7 +383,7 @@ func testReactionGetForPostSince(t *testing.T, ss store.Store, s SqlStore) {
}
func forceUpdateAt(reaction *model.Reaction, updateAt int64, s SqlStore) error {
params := map[string]interface{}{
params := map[string]any{
"userid": reaction.UserId,
"postid": reaction.PostId,
"emojiname": reaction.EmojiName,