[MM-28810] channel_store_categories: check if object is nil after the query (#15635)
* check if onj is nil * channel_store_categories: add tests * reflect review comments * remove store declaraation
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6222e182ca
Коммит
c67c46a684
@@ -6,10 +6,9 @@ package sqlstore
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
|
||||
"github.com/mattermost/gorp"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
|
||||
sq "github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
@@ -843,6 +842,8 @@ func (s SqlChannelStore) addChannelToFavoritesCategoryT(transaction *gorp.Transa
|
||||
var channel *model.Channel
|
||||
if obj, err := transaction.Get(&model.Channel{}, preference.Name); err != nil {
|
||||
return errors.Wrapf(err, "Failed to get favorited channel with id=%s", preference.Name)
|
||||
} else if obj == nil {
|
||||
return store.NewErrNotFound("Channel", preference.Name)
|
||||
} else {
|
||||
channel = obj.(*model.Channel)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user