MM-45994 ensure database operations return their errors (#20857)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c72e9131f4
Коммит
eb37139f16
@@ -5,6 +5,7 @@ package sqlstore
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"io"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/wiggin77/merror"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
)
|
||||
@@ -50,13 +52,18 @@ func MapStringsToQueryParams(list []string, paramPrefix string) (string, map[str
|
||||
}
|
||||
|
||||
// finalizeTransactionX ensures a transaction is closed after use, rolling back if not already committed.
|
||||
func finalizeTransactionX(transaction *sqlxTxWrapper) {
|
||||
func finalizeTransactionX(transaction *sqlxTxWrapper, perr *error) {
|
||||
// Rollback returns sql.ErrTxDone if the transaction was already closed.
|
||||
if err := transaction.Rollback(); err != nil && err != sql.ErrTxDone {
|
||||
mlog.Error("Failed to rollback transaction", mlog.Err(err))
|
||||
*perr = merror.Append(*perr, err)
|
||||
}
|
||||
}
|
||||
|
||||
func deferClose(c io.Closer, perr *error) {
|
||||
err := c.Close()
|
||||
*perr = merror.Append(*perr, err)
|
||||
}
|
||||
|
||||
// removeNonAlphaNumericUnquotedTerms removes all unquoted words that only contain
|
||||
// non-alphanumeric chars from given line
|
||||
func removeNonAlphaNumericUnquotedTerms(line, separator string) string {
|
||||
@@ -82,8 +89,9 @@ func containsAlphaNumericChar(s string) bool {
|
||||
}
|
||||
|
||||
// isQuotedWord return true if the input string is quoted, false otherwise. Ex :-
|
||||
// "quoted string" - will return true
|
||||
// unquoted string - will return false
|
||||
//
|
||||
// "quoted string" - will return true
|
||||
// unquoted string - will return false
|
||||
func isQuotedWord(s string) bool {
|
||||
if len(s) < 2 {
|
||||
return false
|
||||
|
||||
Ссылка в новой задаче
Block a user