diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-12-06 10:49:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 10:49:34 -0500 |
commit | 026553e4f87bfc647a5c03129752e30fc523fa07 (patch) | |
tree | d5403c760151c0fa26fc6d020f7f4326ea9d6f8a /store/sql_channel_store.go | |
parent | dcf11a14d8363c79ab62aefca46834d6daa615ab (diff) | |
download | chat-026553e4f87bfc647a5c03129752e30fc523fa07.tar.gz chat-026553e4f87bfc647a5c03129752e30fc523fa07.tar.bz2 chat-026553e4f87bfc647a5c03129752e30fc523fa07.zip |
Improving command line interface (#4689)
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 89fb8c409..e6b7b80bf 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -502,14 +502,29 @@ func (s SqlChannelStore) GetTeamChannels(teamId string) StoreChannel { } func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel { + return s.getByName(teamId, name, false) +} + +func (s SqlChannelStore) GetByNameIncludeDeleted(teamId string, name string) StoreChannel { + return s.getByName(teamId, name, true) +} + +func (s SqlChannelStore) getByName(teamId string, name string, includeDeleted bool) StoreChannel { storeChannel := make(StoreChannel, 1) + var query string + if includeDeleted { + query = "SELECT * FROM Channels WHERE (TeamId = :TeamId OR TeamId = '') AND Name = :Name" + } else { + query = "SELECT * FROM Channels WHERE (TeamId = :TeamId OR TeamId = '') AND Name = :Name AND DeleteAt = 0" + } + go func() { result := StoreResult{} channel := model.Channel{} - if err := s.GetReplica().SelectOne(&channel, "SELECT * FROM Channels WHERE (TeamId = :TeamId OR TeamId = '') AND Name = :Name AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil { + if err := s.GetReplica().SelectOne(&channel, query, map[string]interface{}{"TeamId": teamId, "Name": name}); err != nil { if err == sql.ErrNoRows { result.Err = model.NewLocAppError("SqlChannelStore.GetByName", MISSING_CHANNEL_ERROR, nil, "teamId="+teamId+", "+"name="+name+", "+err.Error()) } else { |