mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrate from gorp to sqlx in store/sqlstore/command_webhook_store.go (#18517)
* Migrate from gorp to sqlx in store/sqlstore/command_webhook_store.go * fixing small things change `CreatedAt` to `CreateAt` and change GetReplicaX().Select to GetReplicaX().Get Co-authored-by: Saul Pinales <saul021002@gmai.com>
This commit is contained in:
@@ -47,7 +47,10 @@ func (s SqlCommandWebhookStore) Save(webhook *model.CommandWebhook) (*model.Comm
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.GetMaster().Insert(webhook); err != nil {
|
||||
if _, err := s.GetMasterX().NamedExec(`INSERT INTO CommandWebhooks
|
||||
(Id,CreateAt,CommandId,UserId,ChannelId,RootId,UseCount)
|
||||
Values
|
||||
(:Id, :CreateAt, :CommandId, :UserId, :ChannelId, :RootId, :UseCount)`, webhook); err != nil {
|
||||
return nil, errors.Wrapf(err, "save: id=%s", webhook.Id)
|
||||
}
|
||||
|
||||
@@ -70,7 +73,7 @@ func (s SqlCommandWebhookStore) Get(id string) (*model.CommandWebhook, error) {
|
||||
return nil, errors.Wrap(err, "get_tosql")
|
||||
}
|
||||
|
||||
if err := s.GetReplica().SelectOne(&webhook, queryString, args...); err != nil {
|
||||
if err := s.GetReplicaX().Get(&webhook, queryString, args...); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, store.NewErrNotFound("CommandWebhook", id)
|
||||
}
|
||||
@@ -92,7 +95,7 @@ func (s SqlCommandWebhookStore) TryUse(id string, limit int) error {
|
||||
return errors.Wrap(err, "tryuse_tosql")
|
||||
}
|
||||
|
||||
if sqlResult, err := s.GetMaster().Exec(queryString, args...); err != nil {
|
||||
if sqlResult, err := s.GetMasterX().Exec(queryString, args...); err != nil {
|
||||
return errors.Wrapf(err, "tryuse: id=%s limit=%d", id, limit)
|
||||
} else if rows, _ := sqlResult.RowsAffected(); rows == 0 {
|
||||
return store.NewErrInvalidInput("CommandWebhook", "id", id)
|
||||
@@ -115,7 +118,7 @@ func (s SqlCommandWebhookStore) Cleanup() {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := s.GetMaster().Exec(queryString, args...); err != nil {
|
||||
if _, err := s.GetMasterX().Exec(queryString, args...); err != nil {
|
||||
mlog.Error("Unable to cleanup command webhook store.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user