From 0e6f0cfbd68ea7ce24a5f4f71000e2df40ae5194 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 17 Dec 2019 22:33:38 +0530 Subject: [PATCH] MM-21118: Use querybuilder instead of fmt.Sprintf in channelStore (#13385) * MM-21118: Use querybuilder instead of fmt.Sprintf in channelStore We use the querybuilder API instead of just building the query string manually using fmt.Sprintf * Replaced comma with colon --- store/sqlstore/channel_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index da7bd40840..12bf86f161 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -960,7 +960,7 @@ func (s SqlChannelStore) getAllChannelsQuery(opts store.ChannelSearchOpts, forCo } if len(opts.ExcludeChannelNames) > 0 { - query = query.Where(fmt.Sprintf("c.Name NOT IN ('%s')", strings.Join(opts.ExcludeChannelNames, "', '"))) + query = query.Where(sq.NotEq{"c.Name": opts.ExcludeChannelNames}) } return query @@ -2265,7 +2265,7 @@ func (s SqlChannelStore) channelSearchQuery(term string, opts store.ChannelSearc } if len(opts.ExcludeChannelNames) > 0 { - query = query.Where(fmt.Sprintf("c.Name NOT IN ('%s')", strings.Join(opts.ExcludeChannelNames, "', '"))) + query = query.Where(sq.NotEq{"c.Name": opts.ExcludeChannelNames}) } if len(opts.NotAssociatedToGroup) > 0 {