MM-19336 Migrated GetMembersByIds and GetMembersByChannelIds to Squirrel (#19728)

* Ported GetMembersByIds and GetMembersByChannelIds to Squirrel

* Added checks for empty ID lists

* Updated GetAllChannelMembersById to use Squirrel

* Added a method to get the query placeholder directly

* Migrated UpdateMultipleMembers to use a Squirrel query

* Migrated UpdateMultipleMembers to Squirrel

* Initialize a prepared query builder for channelMembersForTeamWithSchemeSelectQuery

* Migrated GetMembersForUser to Squirrel

* Slight improvement for constructMySQLJSONArgs

* Migrated UpdateMemberNotifyProps to Squirrel

* Migrated GetMembers to Squirrel

* Migrated GetMember to Squirrel

* Avoid shadowing err

* Don't set query builder on copy of SqlChannelStore

* Fixed typo in error message

* Fixed missing elipsis

* Shorter SQL generation for GetAllChannelMembersById

* Don't unnecessarily copy the reference

* Use a function to generate the ChannelMember map

* Avoid shadowing err

* Don't use IN for matching multiple possible values

* Initialize the members lists

* Remove check for empty channelIDs list

* Fixed test and removed check for empty list

* Use err2 rather than eerr

Co-authored-by: Tim Scheuermann <tim@plusmid.dev>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Tim Scheuermann
2022-03-10 20:57:09 +01:00
коммит произвёл GitHub
родитель f5b6e09965
Коммит caa30c9bc4
5 изменённых файлов: 215 добавлений и 121 удалений

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

@@ -113,14 +113,13 @@ func constructMySQLJSONArgs(props map[string]string) ([]interface{}, string) {
// Unpack the keys and values to pass to MySQL.
args := make([]interface{}, 0, len(props))
for k, v := range props {
args = append(args, "$."+k)
args = append(args, v)
args = append(args, "$."+k, v)
}
// We calculate the number of ? to set in the query string.
argString := strings.Repeat("?, ", len(props)*2)
// Strip off the trailing comma.
argString = strings.TrimSuffix(strings.TrimSpace(argString), ",")
argString = strings.TrimSuffix(argString, ", ")
return args, argString
}